v-on可以监听多个方法
<template>
<div class="about">
<button @click="myclick('hello','world','你好世界',$event)">点我text</button> <!-- v-on在vue2.x中测试,以下两种均可-->
<button v-on="{mouseenter: onEnter,mouseleave: onLeave}">鼠标进来1</button>
<button @mouseenter="onEnter" @mouseleave="onLeave">鼠标进来2</button> <!-- 一个事件绑定多个函数,按顺序执行,这里分隔函数可以用逗号也可以用分号-->
<button @click="a(),b()">点我ab</button>
<button @click="one()">点我onetwothree</button> <!-- v-on修饰符 .stop .prevent .capture .self 以及指定按键.{keyCode|keyAlias} -->
<!-- 这里的.stop 和 .prevent也可以通过传入&event进行操作 -->
<!-- 全部按键别名有:enter tab delete esc space up down left right -->
<form @keyup.delete="onKeyup" @submit.prevent="onSubmit">
<input type="text" placeholder="在这里按delete">
<button type="submit">点我提交</button>
</form>
</div>
</template>
<script>
export default {
methods: {
//这里是es6对象里函数写法
a() {
console.log("a");
},
b() {
console.log("b");
},
one() {
console.log("one");
this.two();
this.three();
},
two() {
console.log("two");
},
three() {
console.log("three");
},
myclick(msg1, msg2, msg3, event) {
console.log(msg1 + msg2 + "--" + msg3);
console.log(event);
},
onKeyup() {
console.log("you press 'delete'");
},
onSubmit() {
console.log("sumited");
},
onEnter() {
console.log("mouse enter");
},
onLeave() {
console.log("mouse leave");
}
},
};
</script>