vue實(shí)現(xiàn)echarts中HelloWorld柱狀圖
1、先新建好一個(gè)項(xiàng)目,安裝echarts,最好安裝5.0以下版本,5.0易出錯(cuò)
npm install echarts@4.9.0

2、在main.js中全局引入echarts
代碼:import echarts from 'echarts'
????????? ?Vue.prototype.$echarts = echarts;

3、修改helloworld.vue代碼
<template>
<div>
<div style="width:500px;height:500px" ref="chart"></div>
</div>
</template>
<script>
? ? //局部引用
const echarts = require('echarts');
export default{
data(){
return {
}
},
methods: {
initCharts(){
// 基于準(zhǔn)備好的dom,初始化echarts實(shí)例
let myChart = echarts.init(this.$refs.chart);
// 繪制圖表
myChart.setOption({
title: { text: '在Vue中使用echarts' },
tooltip: {},
xAxis: {
data: ["襯衫","羊毛衫","雪紡衫","褲子","高跟鞋","襪子"]
},
yAxis: {},
series: [{
name: '銷(xiāo)量',
type: 'bar',//bar柱狀圖,line折線圖
data: [5, 20, 36, 10, 10, 20]
}]
});
}
},
//一加載頁(yè)面就調(diào)用
mounted () {
this.initCharts();
}
}
</script>
<style>
</style>

4、終端運(yùn)行項(xiàng)目
npm run dev


5、想要?jiǎng)h除vue圖標(biāo),在APP.vue中刪除
<img src="./assets/logo.png">
即可

