vue中加载maptalks图标(markers)点击事件InfoWindow添加按钮点击事件
marker中在content里面写按钮以及按钮的点击事件devDisplay
marker.on('click', function (e) {
// 具体点击执行逻辑
// 开始
marker.setInfoWindow({
'title': 'Marker\'s InfoWindow',
'content': `<div> x:${e.coordinate.x}<br>y:${e.coordinate.y}<br>点名称:${item.name}</div><button οnclick=devDisplay('${e.coordinate.x}','${e.coordinate.y}','${item.name}')>详细信息</button>`
})
marker.openInfoWindow();
console.log(e.coordinate.x, e.coordinate.y, marker);
})
在methods中写devDisplay方法
devDisplay(x, y, name) {
this.detail.model.name = name
this.detail.model.x = x
this.detail.model.y = y
this.detail.dialogVisible = true
// alert(this.detail.model.y)
// console.log(e);
},
重点
mounted() {
window.devDisplay = this.devDisplay
}