Editor.vue:62 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'setHtml')
时间: 2023-10-19 10:31:22 浏览: 164
Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#Object‘的解决方法
在Editor.vue的第62行遇到了一个错误:Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'setHtml')。这个错误是因为在这行代码中,尝试访问一个未定义的属性'setHtml'。根据引用中的代码,setHtml方法被用于设置编辑器的内容。
根据引用中提到的问题,可能是因为初次加载时无法获取到this.$refs.vueWangeditor对象,导致无法进行赋值操作。解决这个问题的方法可以是使用Vue的nextTick方法,在DOM更新后再进行操作。
可以尝试在Editor.vue的第62行代码前添加一个判断条件,确保this.$refs.vueWangeditor对象存在后再调用setHtml方法。代码可以参考如下:
```javascript
if(this.$refs.vueWangeditor){
this.$refs.vueWangeditor.setHtml(info.value);
}
```
这样就可以避免在未定义对象上调用setHtml方法导致的错误。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#Object‘的...](https://download.csdn.net/download/weixin_38640984/13612199)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [vue使用富文本编辑器Wangeditor初次加载获取不到editor对象,导致无法设置回显内容](https://blog.csdn.net/weixin_43485503/article/details/126117621)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文