The problem encountered here is to
introduce ecarts, because before DOM is loaded, option gets the element, and ecarts. Init (document. Queryselect (‘# DOM’)
starts to detect Dom and tries to get it. However, in the case where ecarts is referenced in Vue,
ecarts. Init() has been executed before DOM is loaded, Therefore, an error initialization failed: invalid DOM will be reported
2. Solution:
the root cause is that DOM is not loaded, and ecarts does not detect DOM, so I will let DOM load and then get DOM, here we need to use the
promise in ES6 syntax
//Methods
function initecarts() {
was used // New promise object
is created let newPromise = new Promise((resolve) => {
resolve()
})
// Then the initialization function of ecarts is executed asynchronously newPromise.then(() => {
// This DOM displays the DOM for ecarts
icon echarts.init(DOm)
})
}
// method
function initEcharts () {
// Create a new Promise object
let newPromise = new Promise((resolve) => {
resolve()
})
// then asynchronously execute the initialization function of echarts
newPromise.then(() => {
// This dom is the echarts icon display dom
echarts.init(DOm)
})
}
The method is very simple, which is an asynchronous operation
operation
Read More:
- [Solved] Vue echarts Error: Initialize failed: invalid dom.
- How to Solve the error: initialize failed invalid dom
- [Solved] echarts Draw Errror: echarts-d9fd185e.js:31447 Uncaught (in promise) Error: Initialize failed: invalid dom.
- [Solved] Echarts Error: Uncaught (in promise) Error: Initialize failed: invalid dom.
- [Solved] echarts Error: Error in callback for watcher “chartSource“: “Error: Initialize failed: invalid dom.“
- [Solved] VUE D:\project\vueProject\vue-02\src\components\hello.vue 5:5 error Parsing error: x-invalid-end-tag
- [Solved] vue3vite Error: Failed to resolve import “@vue/server-renderer from “src\App.vue“. Does the file exist
- vue Error: Uncaught SyntaxError: Invalid shorthand property initializer
- [Solved] vue run serve Error: ValidationError: Progress Plugin Invalid Options
- [Solved] Vue Start Project Error: ValidationError: webpack Dev Server Invalid Options
- The addition, deletion and modification of DOM in JS Foundation
- Vue Error: error in mounted hook: TypeError: invalid src type
- How to Use DOM to operate CSS
- Vue2.0: How to Use vue3 api to encapsulate Axios
- [Solved] Vue Error: Uncaught TypeError: Vue.createApp is not a function
- Full screen scrolling by Vue + Vue awesomeswiper
- Vue warn]: vue3 element Component emit Pass Event Error
- [Solved] Vue Route Error: Uncaught TypeError: (0 , vue__WEBPACK_IMPORTED_MODULE_42__.defineComponent) is not a function
- [Solved] Vue3 Error: Failed to resolve component:xxx
- Vue installation @ Vue/cli error: npmerr gyp err