赞
踩
vue的事件对象:
@dragstart=’drag(event)′,在函数中传evevt ,函数中接收一下,事件对象就有了。
- <div class="select-item" draggable='true' @dragstart='drag($event)' v-for="item in items">{{item.name}} //传输事件对象
- </div>
- <script>
- var dom;
- export default{
- data(){
- return{}
- },
- methods: {
- drag:function(event){ //接收事件对象
- dom = event.currentTarget;
- }
- }
- }
- </script>
vue中阻止事件冒泡
1、@click=’show($event)’ 有了事件对象,函数可以利用原生中的 event.cancelBubble=true;
2、@click.stop=’show()’ 只要在事件后面加 .stop 就可以阻止事件冒泡。
vue的中阻止默认事件
1、@click=’show($event)’ 有了事件对象,函数就可以利用原生中的 event.preventDefault();
2、@click.prevent=’show()’ 只要在事件后面加.prevent 就可以阻止默认事件。
vue的键盘事件:
@keydown=’show()’,我们传个$event 也可以在函数中获 event.keyCode 。
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。