1. vue build a good environment on the basis of the foregoing, the initialization WebPACK, using npm i echarts -s download terminal echart
2. After the download is complete global use echart import main.js file
import echarts from 'echarts'
Vue.prototype.$echarts = echarts
3. echart now be used globally, and write a drawchart () {} in the methods in the method, which is written
let myChart = this.$echarts.init(document.getElementById("myChart"));
var option = {
written echart table contents
}
myChart.setOption (Option)
4. Call a method mounted hook function in this.drawchart (), the chart will be displayed on the page id is mychart place
5.echar last adaptation
this.$nextTick(function() {
window.onresize = function() {
laChart.resize (); // each chart are written in a onresize, because this method can only be called once
qualitychart.resize();
safetychart.resize();
machart.resize();
};
});