阅读量:109
在vue中设置点击事件的方法:1.新建html项目,引入vue;2.添加button按钮;3.使用methods方法创建点击事件;4.使用@click属性添加点击事件;
具体步骤如下:
1.首先,新建一个html项目,并在项目中引入vue;
#通过文件方式引入
[removed] [removed]
#通过cdn方式引入
[removed][removed]
2.vue引入好后,在项目中添加一个button按钮;
搜索
3.button按钮添加好后,使用methods方法为按钮创建一个点击事件;
methods:{
searchData:function(){
alert("点击事件")
}
}
4.最后,点击事件创建好后,在按钮中使用@click属性即可添加点击事件;
搜索