vue中e-charts的基本使用

1.安装e-charts项目依赖vue

npm install echarts --savenpm

或者echarts

npm install echarts -Sdom

2.引入项目中this

全局引入(main.js)spa

import echarts from 'echarts'prototype

Vue.prototype.$echarts = echartscode

这种方法是直接绑定在vue实例上,因此在项目中任何页面,直接 this.$echarts 便可xml

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

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);
相关文章
相关标签/搜索