一. 下载echarts
npm install echarts --save
二.在main.js里引入echarts
import echarts from 'echarts'Vue.prototype.$echarts = echarts
三.在vue组件中的使用
<template> <div> <div>乡镇环保指数概况div> <div id="myChart" :style="{width: '400px', height: '400px'}">div> div>template><script type="text/ecmascript-6">export default {
methods:{
drawLine(){
// 基于准备好的dom,初始化echarts实例 let myChart = this.$echarts.init(document.getElementById('myChart')) let that = this // 绘制图表 myChart.setOption({
color: ['#3B93F7', '#7BD7B5'], legend: {
data: ['平邑开发区', '平邑检测站']}, xAxis: [{