leaflet 在地图popup弹框中添加按钮并点击响应(vue2leaflet),设置popup的content属性,添加button

效果如图,点击【进入】按钮,弹出alert提示框。当然这里可以把alert换成其他响应需求。

 首先给popup的content添加button:

<l-popup :content=”profile1-1+ ‘<br><button id=”btnCon”>进入</button>'”></l-popup>

然后在popupopen事件中对按钮绑定click事件:

this.$refs.map.mapObject.on("popupopen", function(e){
    document.getElementById("btnCon").onclick = function(){
         alert('a');
    }
});

 

转载自:https://blog.csdn.net/acoolgiser/article/details/84679264

You may also like...