首页 > 其他分享 >vue 使用 echarts

vue 使用 echarts

时间:2023-01-30 16:24:25浏览次数:41  
标签:5.0 vue 4.9 使用 var main echarts

配置:1.npm 安装 echarts (注意安装5.0之下的版本,安装5.0以上的可能会报错)

cnpm install [email protected]    或者  npm install [email protected]

2.main.js引入

import echarts from 'echarts' Vue.prototype.$echarts = echarts 使用:
<template>
  <div>
    <div class="container">
      <div
        id="main"
        style="width: 600px; height: 400px; margin-top: 40px"
      ></div>
    </div>
  </div>
</template>
 mounted () {
    this.getLoadEcharts()
  },
methods: {

// 基于准备好的dom,初始化echarts实例
      var myChart = this.$echarts.init(document.getElementById('main'))
      

      // 指定图表的配置项和数据
      var option = {
直接引入官网实例即可
}



}

  注意:将官网例子中的echarts替换成this.$echarts。因为echarts是基于html,vue全局引入到main中。

标签:5.0,vue,4.9,使用,var,main,echarts
From: https://www.cnblogs.com/2865----yyyy/p/17076343.html

相关文章