闪开,我要开始ZB了
今日在使用leaflet绘制图形的时候需要用到map.on等监听事件 map.on("mousemove", function onMove(e) {
然而不幸的是tmd(他喵的)老是给爷报错 Cannot read properties of undefined (reading 'on')
百思不得其解兄弟们,后面气得我睡了一觉,梦中受庄周指点(此处省略一万字)
原来map.on这个监听事件是 箭头函数
众所周知,箭头函数里面的this的指向是windows呀
不废话了 解决办法:
在进入箭头函数里面前 先自己定义保存一个this
const myvue = this;