1.安装e-charts项目依赖

npm install echarts --save

或者

npm install echarts -S

2.引入项目中

全局引入(main.js)

import echarts from 'echarts'

Vue.prototype.$echarts = echarts

这种方法是直接绑定在vue实例上,所以在项目中任何页面,直接 this.$echarts 即可

局部引入(需要的页面进行引入)

import echarts from 'echarts'

 

3.初始化echarts

首先在你需要echarts的页面中得创建一个dom元素

<div id="myCharts" ref="myCharts"></div>

其次,在mounted中初始化echarts( 不能写在created中)

1.const  myCharts = this.$echarts.init(this.$refs.myCharts);
2.let options = {
xxx
}
3.
myCharts.setOption(options);
 

 






相关文章:

  • 2022-12-23
  • 2022-02-08
  • 2022-01-24
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
相关资源
相似解决方案