博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
修饰词:.prevent、.stop、.capture与.self
阅读量:3961 次
发布时间:2019-05-24

本文共 1476 字,大约阅读时间需要 4 分钟。

修饰词:.prevent、.stop、.capture与.self

Event.preventDefault:

可阻止时间执行其默认功能:例如:
阻止想submit这样子,本身带有功能的属性,使其本身功能失效!
另一种失效的方法是return false,效果同上!
Event.stopPropagation:
允许事件的默认功能发生,但阻止事件传播

click

Click1的对应的函数会执行,click2的对应的函数不会被执行

.capture与.self

click
methods: {
div1:function(){
console.log('div1'); }, div2:function(){
console.log('div2'); }, div3:function(){
console.log('div3'); }, div4:function(){
console.log('div4'); }, }

当点击click的时候,console.log顺序为:

Div4,div3,div2,div1;

添加:.self

click

结果为:div4,div1

添加:.capture

click

结果为:div3,div2,div4,div1

click

结果为:div2,div4,div3

prevent 是拦截默认事件,passive是不拦截默认事件。

转载地址:http://orezi.baihongyu.com/

你可能感兴趣的文章
【IPFS指南】IPFS的竞争对手们(一)
查看>>
docker更换国内镜像
查看>>
CentOS 下 tree命令用法详解
查看>>
docker上传镜像至Registry时https报错解决方法
查看>>
安装 docker-compose (实测可用,妈妈再也不用担心被墙了)
查看>>
docker下删除none的images
查看>>
Linux提权获取敏感信息方法
查看>>
Ubuntu 16.04开机A start job is running for Raise network interface(5min 4s)解决方法
查看>>
Ubuntu 16.04开机隐藏菜单缩短时间
查看>>
Ubuntu 更换国内源
查看>>
Ubuntu16.04下Docker pull connection refused 解决办法
查看>>
postgres基本操作(个人总结版)
查看>>
The AnimationClip 'Walk' used by the Animation component 'Pig' must be marked as Legacy.
查看>>
《Linux内核设计与实现》- Linux的进程
查看>>
inet_ntoa()
查看>>
POSIX消息队列mq_open问题
查看>>
两个数组a[N],b[N],其中A[N]的各个元素值已知,现给b[i]赋值,b[i] = a[0]*a[1]*a[2]…*a[N-1]/a[i];
查看>>
用户态切换到内核态的3种方式
查看>>
笔试常见的智力题(附答案)
查看>>
内核库函数
查看>>