Vue实战090:Vue使用ECharts图表详解( 二 )


为了方便学习 , 下面附上本文用到的源码:
【Vue实战090:Vue使用ECharts图表详解】> npm install echarts --save**********省略*************+ echarts@4.9.0added 2 packages in 19.44s---------------------------------------------------------------//main.js文件import echarts from 'echarts'// 引入echartsVue.prototype.$echarts = echarts//注册echarts组件export default {name: 'echarts',methods: {drawLine () {let dom = this.$refs.echartsthis.$echarts.init(dom).setOption({title: { text: '在Vue中使用echarts' },tooltip: {},xAxis: {data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]},yAxis: {},series: [{name: '销量',type: 'bar',data: [5, 20, 36, 10, 10, 20]}]})}},mounted () {this.drawLine()}}-------------------------------------------------------------------// 引入基本模板let echarts = require('echarts/lib/echarts')// 引入柱状图组件require('echarts/lib/chart/bar')// 引入提示框和title组件require('echarts/lib/component/tooltip')require('echarts/lib/component/title')


推荐阅读