vuejs如何加载echarts

vuejs如何加载echarts

这篇文章主要介绍vuejs如何加载echarts,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

方法:1、使用“npm install echarts vue-echarts”语句安装vue-echarts;2、在“main.js”文件中引入vue-echarts模块;3、在需要的界面中,根据需要添加echarts代码即可。

本教程操作环境:windows7系统、vue2.9.6版,DELL G3电脑。

vuejs加载echarts

先npm安装vue-echarts

npm install echarts vue-echarts

开发:

main.js

import ECharts from 'vue-echarts'
import 'echarts/lib/chart/line'
Vue.component('chart', ECharts)

HelloWorld.vue

<template>
  <p class="hello">
    <chart ref="chart1" :options="orgOptions" :auto-resize="true"></chart>
  </p>
</template>

<script>
export default {
  name: 'HelloWorld',
  data () {
    return {
      orgOptions: {},
    }
  },
  mounted() {
    this.orgOptions = {
        xAxis: {
            type: 'category',
            data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
        },
        yAxis: {
            type: 'value'
        },
        series: [{
            data: [820, 932, 901, 934, 1290, 1330, 1320],
            type: 'line',
            smooth: true
        }]
    }
  }
}
    </script>

以上是“vuejs如何加载echarts”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注行业资讯频道!