1,首先在 npm 里面安装
npm install echarts --save
2,在mian.js中引入
import Echarts from 'echarts'
Vue.prototype.echarts = Echarts
Vue.use(Echarts)
3,在.vue文件中使用
<div>
<div class="myEcharts" style="width:100px;height:200px" ></div>
</div>
export default{
name:'myEcharts',
data(){},
methods:{
showEchart(){
var myChart = this.$echarts.init(document.getElementByID('myEcharts'));
myChart.setOption({
series:[{
title:'',
name:'',
type:'',
data:[],
...
}]
})
},
},
//可以设个加载过程
mounted(){
this.showEchart();
}
}