vue项目中如何使用echarts
首先下载插件
npm i echarts -S
然后在main.js中引入插件
// 引入
import echarts from 'echarts'
// 注册
Vue.prototype.$echarts = echarts
在需要的组件中初始化图表
// 获取需要生成图表的元素
// 以下是一些常用的配置参数 都有写明详细的注释
initChart () {
let echarts = this.$echarts.init(document.getElementById('charts'))
let option = {
xAxis: {
type: 'category',
data: ['4', '5', '6', '7', '8', '9', '10'],
splitLine: {
show: true, // 纵向分割线显示
lineStyle