v-on指令
用于事件绑定,v-on:事件名=“函数名(形参)”,可以简写成@事件名=“函数名(形参)”
例子:
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title></head><body><id id="app"><input type="text" v-model="message" placeholder="输入...."><p>输入的内容:{{message}}</p><br><input type="button" value="haha" v-on:click="hell"><input type="button" value="hehe" @click="hell"></div></body><script src="/npm/vue/dist/vue.js"></script><script>var vue = new Vue({el: "#app",data: {message: "java"},methods:{hell:function(event){// event表示调用方法的对象,event.target.value表示获取调用这个方法对象的value值。alert(event.target.value);}}})</script></html>