报错提示:Uncaught TypeError: this.$emit is not a function
需求:Echarts柱状图点击事件里进行父子组件传参
解决方法:主要是this指向的问题
方法一:在外部将this重新进行声明
let that=this
this.chart.on('click',function(params) {
console.log(params.name)
that.$emit('reloadPoint',params.name)
})
方法二:使用箭头函数
this.chart.on('click',params=> {
console.log(params.name)
this.$emit('reloadPoint',params.name)
})