一、原本的V4版本按需引入: main.js页面
import Echarts from 'echarts/lib/echarts'
import 'echarts/lib/chart/pie'
import 'echarts/lib/chart/bar'
import 'echarts/lib/chart/line'
Vue.prototype.echarts = Echarts
二、升级版本
!!!注意:要先删除插件,再重新安装插件,要不然是没效果的(我就说咋没效果)
- 删除echarts
npm uninstall echarts --save
- 再重新安装echarts
npm install echarts --save
三、按需处理
- 在main.js页面
参考官方:https://echarts.apache.org/zh/tutorial.html#%E5%9C%A8%E6%89%93%E5%8C%85%E7%8E%AF%E5%A2%83%E4%B8%AD%E4%BD%BF%E7%94%A8%20ECharts
import * as Echarts from 'echarts/core';
import { BarChart, PieChart, LineChart } from 'echarts/charts';
import {
TitleComponent,
TooltipComponent,
GridComponent,
LegendComponent
} from 'echarts/components';
// 引入 Canvas 渲染器,注意引入 CanvasRenderer 或者 SVGRenderer 是必须的一步
import {
CanvasRenderer
} from 'echarts/renderers';
Echarts.use([BarChart, PieChart, LineChart, TitleComponent, TooltipComponent, GridComponent, CanvasRenderer, LegendComponent])
Vue.prototype.echarts = Echarts
四、成功