在vue 中,添加html元素,并在元素中添加点击事件,用原生的onclick来触发事件,将事件挂在window上
mouseClickHandler(f) {
//创建html元素
let contentHTML = "<div style='width:80px; font-size:12px;font-weight:bold; opacity: 0.8;' onclick='toWaringInfo2("+f.id+")'>";
contentHTML += f.headline;
contentHTML += "</div>";
.....
}
//点击事件
toWaringInfo2(data){
console.log(data)
},
//关键
created(){
let _this=this;
window.toWaringInfo2=_this.toWaringInfo2;
},