<template><div class="hello"><form @click.prevent="willDo"><input type="submit" value="提交"/></form><a href="https://www.baidu.com" @click.prevent="willDo">跳转到百度</a></div></template><script>exportdefault{
name:'HelloWorld',data(){return{}},
methods:{willDo(){
console.log(1)// 当点击提交/跳转到百度 的时候,不走原来的方法,改为当前方法}},
computed:{},asynccreated(){}}</script><!-- Add "scoped" attribute to limit CSS to this component only --><style scoped></style>
v-on:keydown / @keydown 键盘按下
<template><div class="hello"><label>v-on:keydown<input type="text" @keydown="keyDown()"/></label></div></template><script>exportdefault{
name:'HelloWorld',data(){return{}},
methods:{keyDown(){
console.log(123)}},
computed:{},asynccreated(){}}</script><!-- Add "scoped" attribute to limit CSS to this component only --><style scoped></style>
v-on:keyup.enter / @keyup.enter 键盘回车修饰符
敲击回车时进行触发的事件
<template><div class="hello"><label>v-on:keyup.enter回车修饰符<input type="text" @keyup.enter="keyupEnter()"/></label></div></template><script>exportdefault{
name:'HelloWorld',data(){return{}},
methods:{keyupEnter(){
console.log(123)}},
computed:{}}</script><!-- Add "scoped" attribute to limit CSS to this component only --><style scoped></style>