Vue环境下——echarts的配置步骤

第一步:通过npm 安装  Echarts

npm install echarts --save

 

第二步:在main.js里面配置

//引入echarts
import * as echarts from 'echarts'

//配置原型,全局使用
Vue.prototype.$echarts = echarts

 

第三步:在页面内使用

(1)HTML

<div id="main" style="min-width:600px;height:30px;"></div>

(2)js


drawChart(){

  //
基于准备好的dom,初始化echarts实例   var myChart = this.$echarts.init(document.getElementById('main'));   // 在option中对图表进行配置   var option = {}   // 使用刚配置的数据显示图表。   myChart.setOption(option);


}

 

posted @ 2021-05-27 18:00  最初的样子  阅读(279)  评论(0编辑  收藏  举报