Home  >  Article  >  Web Front-end  >  How to load echarts in vuejs

How to load echarts in vuejs

青灯夜游
青灯夜游Original
2021-09-28 16:02:102504browse

Method: 1. Use the "npm install echarts vue-echarts" statement to install vue-echarts; 2. Introduce the vue-echarts module in the "main.js" file; 3. In the required interface, according to Just add the echarts code.

How to load echarts in vuejs

The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.

vuejs loads echarts

First npm install vue-echarts

npm install echarts vue-echarts

Development :

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>

This is the end. I tried packaging it, but no error was reported~

Related recommendations: "vue.js Tutorial"

The above is the detailed content of How to load echarts in vuejs. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to use less in vuejsNext article:How to use less in vuejs