vue项目开发如何引入echarts图表 发布时间:2025/01/14 vue项目开发如何引入echarts图表,下面编程教程网小编给大家详细介绍一下具体流程! 安装脚手架 npm install echarts -S 复制代码 全局引入 import echarts from 'echarts' Vue.prototype.$echarts = echarts 复制代码 创建一个容器 <div id="bar" style="width: 300px; height: 300px;"></div> 复制代码 创建图表方法 getBar() { let myChart = this.$echarts.init(document.getElementById("bar")); // 配置参数 let config = { title: { text: "柱状图" }, tooltip: {}, xAxis: { data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"], }, yAxis: {}, series: [ { name: "销量", type: "bar", data: [5, 20, 36, 10, 10, 20], }, ], }; // 设置参数 myChart.setOption(config); }, 复制代码 以上是编程学习网小编为您介绍的“vue项目开发如何引入echarts图表”的全面内容,想了解更多关于 vuejs 内容,请继续关注编程基础学习网。