今天我要給 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'
這樣就可以了。