How to load echarts in vuejs

青灯夜游
Release: 2023-01-11 09:22:44
Original
2499 people have browsed it

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
Copy after login

Development :

main.js

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

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template