1. Install e-charts project dependencies
npm install echarts --save
or
npm install echarts -S
2. Introduction of project
Global introduction (main.js)
import echarts from 'echarts'
Vue.prototype.$echarts = echarts
这种方法是直接绑定在vue实例上,所以在项目中任何页面,直接 this.$echarts 即可
Introduced locally (pages need to be introduced)
import echarts from 'echarts'
3. initialization echarts
You must first create a dom element in the page you need echarts
<div id="myCharts" ref="myCharts"></div>
Secondly, in the initialization echarts mounted in ( 不能写在created中
)
1.const myCharts = this.$echarts.init(this.$refs.myCharts);
2.let options = {
xxx
}
3.myCharts.setOption(options);