处理高德舆图label增加的点击事宜在挪动端无效
近日工作中须要用到高德舆图在PC端和挪动端同时适配的需求,在PC端撸代码和调试一切顺利,但是在将项目在平板中测试
时,发明绑定在label中的click事宜没法触发;经由历程种种调试发明应该是高德在挪动端的marker上屏障了click事宜;
原代码以下:
self.pointers[item].setLabel({
//label默许蓝框白底左上角显现,款式className为:amap-marker-label
offset: new AMap.Pixel(25, 5), //右边
zIndex: 99,
content:
"<div class='map-label'><span class='map-label-name'>" +
self.allData.filter(b => b.seqno == item)[0].shortTitle +
"</span><a href='javascript:void(0)' class='map-label-link' id='label-" +
item +
"' onclick='clickLink(this, event)' seqno='" +
item +
"'><i class='iconfont icon-arrow-double-right'></i></a></div>"
});
处理方案:手动给label增加touchstart事宜
let btn = document.getElementById("label-" + item);
btn.addEventListener(
"touchstart",
function(event) {
self.$router.push({
path: "/screenProject",
query: { seqno: item }
});
},
false
);
特此纪录一下踩坑历程!