<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
<style type="text/css">
.demo1{
background-color: #00FFFF;
}
.box1{
background-color: #5F9EA0;
}
.box2{
background-color: #FF7F50;
}
ul{
width: 100px;
height: 200px;
background-color: #FF4500;
overflow: auto;
}
li{
height: 100px;
width: 100px;
background-color: #008000;
}
</style>
</head>
<body>
<div id="app">
<!-- 点击事件修饰符,阻止事件默认事件-->
<a href="www.baidu.com" @click.prevent="showInfo">点我</a>
<!-- 阻止事件冒泡-->
<div class="demo1" @click="showInfo2">
<button @click.stop="showInfo">点击按钮</button>
</div>
<!-- 事件只出发一次-->
<button @click.once="showInfo">只单机一次</button>
<!-- 事件捕获模式-->
<div class="box1" @click.capture="showInfo3(1)">
div1
<div class="box2" @click="showInfo3(2)">
div2
</div>
</div>
<!-- 事件的默认行为会立即执行。无需等待事件回调完毕执行
@scroll滚动条滑动事件()
@wheel滚动条滑动事件
-->
<ul @wheel.passive="conlog">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
<script type="text/javascript">
new Vue({
el:'#app',
methods:{
showInfo(e){
alert("helloword")
},
showInfo2(){
alert("你好")
},
showInfo3(msg){
alert(msg)
},
conlog(){
for(var i=0;i<1000;i++){
console.log('@')
}
}
}
})
</script>
</body>
</html>