3.4 v-on : 绑定事件监听
有时候,我们需要给元素绑定事件,vue 中提供了指令 v-on 来进行事件的绑定。用法:
v-on:事件名="方法",例如:v-on:click=“alert”。
v-on:事件名, 可以缩写为: @事件名
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
</head>
<div>
<button v‐on:click="hello">hello</button>
</div>
</html>
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 Eternal Night
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果