npm install echarts -S

  

1.按需引入

新建echarts.js公共引入

// 文件路径 @/lib/echarts.js 自行配置
 
 // 加载echarts,注意引入文件的路径
 import echarts from 'echarts/lib/echarts'
 
 // 再引入你需要使用的图表类型,标题,提示信息等
 import 'echarts/lib/chart/bar'
 import 'echarts/lib/component/legend'
 import 'echarts/lib/component/title'
 import 'echarts/lib/component/tooltip'
 
 export default echarts

  在echart.vue文件引入echarts.js文件

<template>
  <div class="about">
    <!-- <h2>This is an aboutEchart page</h2> -->
    <div ></div>     
  </div>
</template>
<script>
import echarts from '@/common/echarts'

2.全局引入echarts

 

在main.js中

// 引入echarts
import echarts from 'echarts'
Vue.prototype.$echarts = echarts

 

相关文章:

  • 2021-12-26
  • 2021-12-29
  • 2022-12-23
  • 2023-04-03
  • 2022-12-23
  • 2021-10-29
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案