按照這里的操作
https://github.com/ecomfe/vue-echarts/blob/master/README.zh_CN.md
安裝 echarts
修改



// The Vue build version to load with the `import` command // (runtime-only or standalone) has been set in webpack.base.conf with an alias. import Vue from 'vue' import App from './App' import router from './router' import ECharts from 'vue-echarts' // 在 webpack 環境下指向 components/ECharts.vue // 手動引入 ECharts 各模塊來減小打包體積 import 'echarts/lib/chart/bar' import 'echarts/lib/component/tooltip' import 'echarts-gl' // 注冊組件后即可使用 Vue.component('v-chart', ECharts) Vue.config.productionTip = false /* eslint-disable no-new */ new Vue({ el: '#app', router, components: { App }, template: '<App/>' })
結合 這里的例子,它是用js鏈接
https://echarts.apache.org/zh/tutorial.html#5%20%E5%88%86%E9%92%9F%E4%B8%8A%E6%89%8B%20ECharts
代碼有點不一樣
頁面代碼
<template>
<div>
<v-chart :options="options" style="width: 600px;height:400px;"></v-chart>
</div>
</template>
<script>
export default {
data () {
return {
options: {
title: {
text: 'ECharts 入門示例'
},
tooltip: {},
legend: {
data:['銷量']
},
xAxis: {
data: ["襯衫","羊毛衫","雪紡衫","褲子","高跟鞋","襪子"]
},
yAxis: {},
series: [{
name: '銷量',
type: 'bar',
data: [5, 20, 36, 10, 10, 20]
}]
}
}
}
}
</script>
<style>
</style>
效果

例子2
<template>
<div>
<v-chart :options="options" style="width: 600px;height:400px;"></v-chart>
</div>
</template>
<script>
export default {
data () {
return {
options: {
series: {
type: 'pie',
data: [
{name: 'A', value: 1212},
{name: 'B', value: 2323},
{name: 'C', value: 1919}
]
}
}
}
}
}
</script>
<style>
</style>
效果圖

