We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
代码示例:/lesson07/01. 事件修饰符.html
通过事件修饰符可以实现为事件添加event.preventDefault()、event.stopPropagation()等操作。 事件修饰符介绍如下:
普通修饰符的例子: JavaScript:
let vm = new Vue({ el: '#app', // 根元素或挂载点。 data: {}, methods: { fn1() { alert('fn1') }, fn2() { alert('fn2') }, submit() { alert('submit') }, } })
HTML:
<div id="app"> <div v-on:click="fn1()"> <form action="" v-on:submit.prevent="submit()"> <input type="submit" value="按钮" v-on:click.prevent.stop.once="fn2()"> </form> </div>
代码示例:/lesson07/02. 按键修饰符.html
JavaScript:
let vm = new Vue({ el: '#app', data: {}, methods: { fn1() { alert('回车') }, fn2() { alert('ctrl+回车') }, } })
<div> <!-- 按下回车键时弹窗,也可以写成v-on:keydown.13 --> <input type="text" v-on:keydown.enter="fn1()"> <!-- 按键修饰符也支持组合 --> <input type="text" v-on:keydown.ctrl.enter="fn2()"> </div>
The text was updated successfully, but these errors were encountered:
No branches or pull requests
阅读更多系列文章请访问我的GitHub博客,示例代码请访问这里。
事件修饰符
通过事件修饰符可以实现为事件添加event.preventDefault()、event.stopPropagation()等操作。
事件修饰符介绍如下:
普通修饰符的例子:
JavaScript:
HTML:
按键修饰符
JavaScript:
The text was updated successfully, but these errors were encountered: