vue.runtime.esm.js:1887 Error: Initialize failed: invalid dom.
时间: 2023-11-01 12:22:10 浏览: 326
Vue.js前端 JavaScript 框架
这个错误是由于在Vue中引用echarts时,当模板的DOM还没有加载完成时,echarts.init()函数就已经开始执行,所以会报错"Initialize failed: invalid dom"。为了解决这个问题,可以使用Promise来异步执行echarts的初始化函数。在初始化之前,新建一个Promise对象并将其resolve,在resolve后再执行echarts.init()函数。这样可以确保在DOM加载完成后再进行echarts的初始化操作,避免报错。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [v2.6.10-vue.js&vue.min.js&vue.common.js&vue.runtime.js等14个资源](https://download.csdn.net/download/zhuyangyong/87564012)[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: Initialize failed: invalid dom 之 dom加载出现的问题](https://blog.csdn.net/weixin_52309490/article/details/118222199)[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 ]
阅读全文