1.首先安装echarts:
- npm install echarts -S
或 - cnpm install echarts -S
安装完成之后,我们就可以开始引入我们需要的echarts了,接下来介绍几种使用echarts的方式。
全局引用:
首先在main.js中引入echarts,将其绑定到vue原型上:
import echarts from 'echarts'
Vue.prototype.$echarts = echarts;
接着,我们就可以在任何一个组件中使用echarts了,接下来我们在初始化项目中的helloWorld组件中使用echarts配置图标,具体如下:
<div style="width:355px;height:280px" ref="chart"></div>
import '../../config/shine'//这里我引用了图表的主题,可以自定义颜色
methods:{
initCharts() {
let myChart = this.$echarts.init(this.$refs.chart,"shine");
// 绘制图表
myChart.setOption(