echarts按需引入

2021-10-11 01:12:17 字數 1076 閱讀 3899

這篇文章只對echarts v4.x 有效

官方更新到v5.x 後 可以檢視官方例項 檢視完整**->按需引入

echarts 的完整包太大了,但是在專案中,其實很多都是用不上的,所以按需引入是很有必要的

import echarts from

"echarts/lib/echarts"

;import

"echarts/lib/chart/bar"

;import

"echarts/lib/chart/line"

;import

"echarts/lib/chart/pie"

;import

"echarts/lib/component/legend"

;import

"echarts/lib/component/title"

;import

"echarts/lib/component/tooltip"

;import

"echarts/lib/component/grid"

;// import 'echarts/theme/macarons' // echarts theme

import installtheme from

"./echarts-theme"

;installtheme

(echarts)

;export

default echarts;

export

default

function

installtheme

(echarts),}

, tooltip:

, crossstyle:

, shadowstyle:,}

,}, grid:

, line:,}

; echarts.

registertheme

("macarons"

, theme)

;}

按需引入echarts元件

echarts元件非常多,有時候我們的業務就需要兩三個不多,這時候如果全部引入的就會導致打包過大,這時候就可以按需引入。const echarts require echarts lib echarts 引入折線圖 require echarts lib chart line 餅圖 require ...

VUE mint ui按需引入總結

第一步 安裝mint ui 這裡不細說 第二步 執行npm install babel plugin component 文件寫的npm install babel plugin component d,我按文件知道裝了報錯,專案無法編譯,可能是和版本有關係?多次嘗試後把 d刪掉就可以 第三部 修改...

VUE mint ui按需引入總結

第一步 安裝mint ui 這裡不細說 第二步 執行npm install babel plugin component 文件寫的npm install babel plugin component d,我按文件知道裝了報錯,專案無法編譯,可能是和版本有關係?多次嘗試後把 d刪掉就可以 第三部 修改...