vue拼接html中onclick的觸發方式,vue中的onclick,vue觸發onclick,vue拼接html

1.首先你有一段拼接的html代碼

let conten=`<button οnclick="come()">點我</button>`;

2.然後你需要在methods中有一個函數

methods:{
	come:function(){
		alert('你好,再見!')
	},
}

3.下一步就是連接起橋樑的關鍵點

created(){
	let _this=this;
	window.come=_this.come;
},
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章