1、方法一
創建dom
const img = new Image();
img.src = i.info.img;
img.onclick = function () {
console.log(999);
}
2、方法二
this.map.openInfoWindow(infoWindow, targetpoint); // 開啟信息窗口
if (!infoWindow.isOpen()) {
//如果沒有打開,則監聽打開事件,獲取按鈕,添加事件
infoWindow.addEventListener("open", function () {
document.getElementById("test"+i.id).onclick = function (e) {
that.isVisible = true;
that.imgSrc = i.info.img;
}
})
} else {
//如果沒有打開,則監聽打開事件,獲取按鈕,添加事件
document.getElementById("test"+i.id).onclick = function (e) {
that.isVisible = true;
that.imgSrc = i.info.img;
}
}