mpvue demand introduced echarts

We all know that small file size can not exceed 2M, after the introduction of echarts in the project, the file size far beyond the 2M. Because echarts default file that contains all the code charts, so the file size will be larger. Solution is as follows:

 

installation

First, let's install the following two dependencies

cnpm install mpvue-echarts
cnpm install echarts

 

Custom echarts

To build code files echarts official website online, according to their needs, select the appropriate charts and components, and then download the file. Official website address

 

Replace node_modules file

Folders found in the file echarts node_modules dependent files, enter dist folder, rename the file you just downloaded look for: diy_echarts.js, then put dist folder. Can then be introduced in the assembly, is introduced as follows:

import echarts from 'echarts/dist/diy_echarts'
import mpvueEcharts from 'mpvue-echarts'

 

MpvueEcharts assembly is then used in the code on it.

 

Guess you like

Origin www.cnblogs.com/Mrrabbit/p/11425773.html