vue项目中使用echarts的几种方式

    想要在项目中使用echarts,首先需要在项目中安装echarts

    可以运行

      1.   npm install echarts -S // 或

                     2.   cnpm  install  echarts -S

    安装完成之后,可以在项目中全局使用,也可以在项目中局部使用。

 全局引用 :

    首先,在main.js中引入echarts,将其绑定到vue的原型上。

       1.   import echarts from 'echarts'

                 2.   Vue.prototype.$echarts = echarts

               然后,可以在各个组件中使用echarts。

   局部使用:

    如果不想全局使用,只在单个组件中使用,只要在对应组件内部引入即可;

    const  echarts = require('echarts')

  

猜你喜欢

转载自www.cnblogs.com/lovemeiling/p/11770946.html