vuejs怎么加载echarts
时间:2022-02-11 17:15
方法:1、使用“npm install echarts vue-echarts”语句安装vue-echarts;2、在“main.js”文件中引入vue-echarts模块;3、在需要的界面中,根据需要添加echarts代码即可。 本教程操作环境:windows7系统、vue2.9.6版,DELL G3电脑。 vuejs加载echarts main.js HelloWorld.vue 到这里就结束了。试过打包了,没报错~ 相关推荐:《vue.js教程》 以上就是vuejs怎么加载echarts的详细内容,更多请关注gxlsystem.com其它相关文章!先npm安装vue-echarts
npm install echarts vue-echarts
开发:
import ECharts from 'vue-echarts'
import 'echarts/lib/chart/line'
Vue.component('chart', ECharts)
<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>