//1.安装
npm i --save lodash
//2.main.js引入,直接在组件中引入
// import _ from 'lodash'
//Vue.prototype._ = _
//3.组件中
import _ from 'lodash'
mounted() {
this.chart = this.$echarts.init(this.$refs.chart)
this.chart.setOption(this.createOption(), true)
window.addEventListener('resize', this.resizeFn)
},
beforeDestroy() {
window.removeEventListener('resize', this.resizeFn)
},
methods: {
resizeFn:_.debounce(function(){
this.resizeChart()
},150),
resizeChart(){
console.log('=====================')
//如果字体大小需要计算
//this.chart.setOption(this.createOption(), true)
this.chart.resize()
},
createOption() {。。。。。}
}