本教程操作环境:windows7系统、vue2.9.6版,dell g3电脑。
vuejs加载echarts
先npm安装vue-echartsnpm 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>
到这里就结束了。试过打包了,没报错~
相关推荐:《vue.js教程》
以上就是vuejs怎么加载echarts的详细内容。
