<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>vue</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.js"></script>
</head>
<body>
<div id="app">
<button v-on="{mouseenter:onenter,mouseleave:outmouse}" v-on:click="dinn">点我</button>
</div>
<script src="app.js"></script>
</body>
</html>
var app = new Vue({
el:'#app',
data:{
},
methods:{
dinn:function()
{
console.log('clicked');
},
onenter:function()
{
console.log('mouse enter');
},
outmouse:function()
{
console.log('mouse leave');
}
}
});
表单
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>vue</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.js"></script>
</head>
<body>
<div id="app">
<button v-on="{mouseenter:onenter,mouseleave:outmouse}" v-on:click="dinn">点我</button>
<from v-on:keyup.enter="onKeyup" v-on:submit.prevent="onSubmit">
<input type="text">
<button type="submit">提交</button>
</from>
</div>
<script src="app.js"></script>
</body>
</html>
var app = new Vue({
el:'#app',
data:{
},
methods:{
dinn:function()
{
console.log('clicked');
},
onenter:function()
{
console.log('mouse enter');
},
outmouse:function()
{
console.log('mouse leave');
},
onKeyup:function()
{
console.log('key press');
},
onSubmit:function()
{
console.log('submited');
},
}
});