假如在地图的label 上有个按钮,如何触发点击事件
注意:函数动态参数外面要加个引号(下面的转义单引号),否则不能正确传递参数
代码语言:javascript复制let stationSerial = "s001"
let labelContent='<div style="position:absolute;width:calc(100% - 20px);bottom:-40px;"><img src=' pointerPic ' onclick="goScada('' stationSerial '')"/></div>'
需要在window上注册这个事件
代码语言:javascript复制<script>
import router from '@/router'
function goScada(stationSerial){
router.push({path:"/scadaMonitor/scada",query:{stationSerial:stationSerial}})
}
window.goScada = goScada
export default {
data(){
return {}
}
}
</script>