v-on指令
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <div id="app"> <button v-on:click="onClick()" v-on="{mouseenter:onEnter,mouseleave:onOut}">点我吧</button> <!--<form v-on:submit="onSubmit($event)">--> <form @keyup.enter="onKeyup" v-on:submit.prevent="onSubmit"> <!--<form v-on="k" v-on:submit.stop="onSubmit">--> <input type="text"> <input type="submit" value="提交"> </form> </div> <script src="../lib/vue.js"></script> <script src="js/main.js"></script> </body> </html>
var app = new Vue(
{
el:"#app",
data:{
},
methods:{
onClick:function () {
console.log("点击了")
},
onEnter:function () {
console.log("进来了")
},
onOut:function () {
console.log("出去了")
},
onSubmit:function (e) {
e.preventDefault();
console.log("表单提交")
},
onKeyup:function () {
console.log("huichecaozuo ")
}
}
}
)
本文来自博客园,作者:一石数字欠我15w!!!,转载请注明原文链接:https://www.cnblogs.com/52-qq/p/8386272.html