2.事件对象$event的使用
文章目录
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>事件对象$event</title>
<script src="js/vue.js"></script>
<script>
window.onload=function(){
let vm=new Vue({
el:'div',
methods:{
print(e){
console.log(e);
console.log(e.type);
console.log(e.target);//DOM对象
console.log(e.target.innerHTML);
console.log(this);
}
}
});
}
</script>
</head>
<body>
<div>
<button @click="print($event)">Click Me</button>
<button @click="print">Click Me</button>
</div>
</body>
</html>
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论