如何在vue-cli中引用使用echarts插件
作者:互联网
下载 cnpm install echarts -S
在mian.js文件中引入
const ECharts =require('echarts') Vue.prototype.$echarts = ECharts; 在chart.vue文件中使用<template> <div> <div ref="chart" style="width: 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>
标签:10,插件,vue,20,cli,drawLine,chart,data,echarts 来源: https://www.cnblogs.com/shanchui/p/14728028.html