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;
},
发布了15 篇原创文章 · 获赞 2 · 访问量 588

猜你喜欢

转载自blog.csdn.net/weixin_43728978/article/details/104530261