下载 cnpm install echarts -S
在mian.js文件中引入
const ECharts =require('echarts')
Vue.prototype.$echarts = ECharts;
在chart.vue文件中使用
<template> <div> <div ref="chart" style=" 300px; height: 300px"></div> </div> </template> <script> export default { mounted() { this.drawLine(); }, methods: { drawLine() { let mychart = this.$echarts.init(this.$refs.chart); mychart.setOption({ xAxis: { data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"], }, yAxis: {}, series: [ { name: "销量", type: "bar", data: [5, 20, 36, 10, 10, 20], }, ], }); }, }, }; </script> <style> </style>