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'

 

這樣就可以了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM