此地图存在于Vue组件内部,我正在尝试使用
this.$emit('somethingHappened', HighmapsEventObject)
mounted () {
Highcharts.mapChart(this.$el, {
series: [{
events: {
click: () => {
in here
}
}
}]
})
}
,如
mounted () {
Highcharts.mapChart(this.$el, {
series: [{
events: {
click: () => {
`this.$emit('somethingHappened', HighmapsEventObject)`
}
}
}]
})
}
但显然,this
此时引用了Highmap的this
而不是Vue组件的this
所以我试图做这样的事情:
mounted () {
Highcharts.mapChart(this.$el, {
series: [{
events: {
click: (e) => {
this.$emit('somethingHappened', e)
}
}
}]
}).bind(this)
}
但我明白了:
... default.a.mapChart(...).bind is not a function
我无法弄清楚如何将Vue组件的this
传递给highmaps构造函数,而Vue自然不会听CustomEvent
,所以我无法弄清楚如何调度在该回调中的事件,以便Vue知道它发生了。
mounted () {
Highcharts.mapChart(this.$el, {
series: [{
events: {
click: (e) => {
let event = new CustomEvent('mapclicked', {
detail: e
})
e.target.dispatch(event)
}
}
}]
})
}
所以我的问题,最后,问题是如何:在Vue中监听CustomEvent
,或者b:将Vue的this
绑定到Highmaps构造函数?
非常感谢