<!DOCTYPE html>标签:vue,console,log,vm,js,点击,Vue,023,event From: https://blog.51cto.com/u_15356972/6085197
<html lang="en">
<head>
<meta charset="UTF-8">
<title>事件绑定</title>
<script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
<div id="root">
<h2>{{name}}</h2>
<button @click="showInfo">点击我,显示Vue点击事件</button>
</div>
<script type="text/javascript">
Vue.config.productionTip = false;
const vm = new Vue({
el:'#root',
data:{
name:'虾米大王'
},
methods:{
showInfo(event){
//console.log(event.target.innerText); //可以接收event参数
//console.log(this === vm); // this对象就是vm实例
alert('点击了我,显示提示');
}
}
})
</script>
</body>
</html>