1.引入依赖
npm install echarts --save
2.在template中写
<template> <div> <el-card> <div id="mychart" :style="{height:height,width:width}"></div> </el-card> </div> </template>
3.在scrpit中导入,并使用
<script> import * as echarts from 'echarts'
export default { name:'echarts',
data() { return { height:'300px', width:'800px', } },
methods:{ showEchart(){ // 基于准备好的dom,初始化echarts实例 let myChart = echarts.init(document.getElementById('mychart')) // 绘制图表 myChart.setOption({ title: { text: 'ECharts 入门示例' }, tooltip: {}, xAxis: { data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子'] }, yAxis: {}, series: [ { name: '销量', type: 'bar', data: [5, 20, 36, 10, 10, 20] } ] }); }, } mounted() { this.showEchart() }, }标签:10,20,elementui,admin,showEchart,data,echarts From: https://www.cnblogs.com/luzanzan/p/17508906.html