Vue introduces ecarts, init initializes and reports an error
1. Download ecarts
npm install echarts --save
2. I have only one page to refer to ecarts, so I directly introduce it into the page
import echarts from 'echarts'
3. Write corresponding examples in methods
myEcharts() {
this.chart = echarts.init(document.getElementById('main'))
this.chart.setOption({
tooltip: {
trigger: 'item',
formatter: '{a} <br/>{b} : {c} ({d}%)'
},
legend: {
bottom: 10,
left: 'center',
data: ['rented', 'not rented', 'booked']
},
series: [
{
name: 'Vehicle Rental Status',
type: 'pie',
radius: '55%',
center: ['50%', '40%'],
data: [
{ value: 40, name: 'rented' },
{ value: 30, name: 'not rented' },
{ value: 30, name: 'booked' }
],
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
})
}
4. Reference method in mounted
mounted() {
this.myEcharts()
}
Results an error was reported, init initialization error was reported
it took half an hour to find out the reason, because the import mode was wrong
the original import accessories from 'accessories'
should be changed to Import * as accessories from' accessories'
. The updated writing method in the official website. After modification, refresh the page
if ecarts is needed in many parts of the system, it can be introduced globally in main.js
import * as echarts from 'echarts'
Vue.prototype.$echarts = echarts
Read More:
- In Vue, use echorts to report an error: “typeerror: cannot read property ‘init’ of undefined” error reporting reason and solution
- An error is reported when the electron Vue Vue component introduces the electron
- The echots in Vue reports an error. After obtaining the DOM element, the chart can be displayed. The console still reports an error
- Vue references echats and reports an error initialize failed: invalid DOM
- Reference error: ecarts is not defined
- Vue3. X reports an error using vantui. Failed to resolve component: Van-**-**
- Vue console reports an error duplicate keys detected: ‘XXXX’. This may cause an update error. Solution
- Vue router click the menu bar and the same module reports an error Vue router.esm.js? 2215:2065 Uncaught (in promise) Error
- Vue Alain startup command yarn serve reports an error
- Vue reports an error sasserror: expected newline
- Vue + TS reports an error after configuring the path alias
- The Vue parent component uses ref to call the sub component method and reports an error
- Vue agent reports an Error 404 nginx configuration method
- Vue install reports an error operation not allowed
- Vue project reports an error on ie11 white screen. Script1002: syntax error
- Vue executes NPM run Dev and reports an error: missing script: dev
- Hadoop reports an error. Cannot access scala.serializable and python MapReduce reports an error
- HTML method IE8 reports an error, IE8 jQuery Ajax obtains static resources reports an error, typeerror denies access
- The file server reports an error of 413, and the file uploaded by nginx reports an error of 413 request entity too large
- Vue introduction path is correct, but it always reports an error: already included file name‘ ××ב differs from file name ‘ ××ב only in casing.