vue2-editor Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '_c')
时间: 2023-08-25 21:19:09 浏览: 178
根据提供的引用内容,报错"Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'comcode')"和"Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '_c')"可能是由于在使用`monaco.editor.create`方法时,没有正确获取到DOM节点或者DOM节点未正确绑定ref导致的。
解决办法是检查一下DOM元素上绑定的ref的拼写是否与函数中的一致,并确保在Vue2中使用`this.$refs.xxx`来获取DOM元素,而在Vue3中需要在setup函数中声明一个变量并返回出去,并在DOM元素上以该变量名绑定ref。此外,在获取DOM节点的时机上,如果使用的是Vue3,则需要使用`nextTick`来确保在DOM渲染完成后再获取DOM节点。
因此,您可以检查一下代码中DOM元素的ref绑定是否正确,并根据您使用的是Vue2还是Vue3来确定正确的获取DOM节点的方法。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [vue Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘comcode‘)](https://blog.csdn.net/jungeCSND/article/details/130059965)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [Uncaught (in promise) TypeError: Cannot readproperties of null (reading “addEventListener“)](https://blog.csdn.net/weixin_46015333/article/details/127407308)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文