Home > Article > Web Front-end > How to load echarts in vuejs
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.
The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.
vuejs loads 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>
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!