创建echarts的基本模板
作者:互联网
创建echarts的基本模板
<template>
<div class="com-container">
<div class="com-chart" ref="trend_ref"></div>
</div>
</template>
<script>
import axios from 'axios'
export default {
data(){
return{
chartInstance:null,
allData:null
}
},
mounted(){
this.initChart();
this.getData();
this.screenAdapter();
window.addEventListener('resize',this.screenAdapter);
},
destroyed(){
window.removeEventListener('resize',this.screenAdapter);
},
methods:{
initChart(){
const initOption ={};
this.chartInstance = window.echarts.init(this.$refs.trend_ref);
this.chartInstance.setOption(initOption);
},
async getData(){
//得到数据
this.updateChart();
},
updateChart(){
const dataOption ={};
this.chartInstance.setOption(dataOption);
},
screenAdapter(){
const adapterOption ={};
this.chartInstance.setOption(adapterOption);
this.chartInstance.resize();
}
}
}
</script>
<style>
</style>
标签:const,创建,setOption,window,screenAdapter,chartInstance,echarts,模板 来源: https://blog.csdn.net/qq_38899062/article/details/110750044