echarts 踩坑 : 为什么效果出不来?看看有没有正确引入

今天我要给 echarts 组件加个 dataZoom 功能,结果发现没有效果。

后来发现是引入 echarts 模块的问题。

如果是按需引入的话,必须引入相应的功能模块才能使用相应的功能。

举例:

import echarts from 'echarts/lib/echarts'
import 'echarts/lib/chart/bar'
import 'echarts/lib/component/tooltip'
import 'echarts/lib/component/legend'
import 'echarts/lib/component/title'

我没有引入 dataZoom ,所以不能使用。

import echarts from 'echarts/lib/echarts'
import 'echarts/lib/chart/bar'
import 'echarts/lib/component/tooltip'
import 'echarts/lib/component/legend'
import 'echarts/lib/component/title'
import 'echarts/lib/component/dataZoom'

这样就可以了。

猜你喜欢

转载自www.cnblogs.com/foxcharon/p/11923509.html
今日推荐