Vue: initialize failed: invalid DOM [How to Solve]

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: