博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
微信小程序学习笔记 事件冒泡
阅读量:6984 次
发布时间:2019-06-27

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

在 pages 下的 index.wxml 文件里面写主体框架

爷爷
父亲
儿子
绑定相同的事件点击 view3 的时候会触发 view2 和 view1 如果想阻止冒泡在 view3 上用 catchtap 事件来绑定就好了 复制代码

在 pages 下的 index.js文件里面设置操作逻辑

//事件处理函数   //  说说 event 里面几个重要的属性 currentTarget 绑定事件 target 可以查看到时触发事件源,其中在 currentTarget 里面有个属性叫 dataset 可以显示自己手动添加的数据例如 data-title = '我是标题' 最后  "我是标题"  会在 dataset  中显示出来    view1Click :function(event){        console.log('view1Click');        console.log(event);    },    view2Click :function(){        console.log('view2Click')    },    view3Click :function(event){        console.log('view3Click');        console.log(event)    },复制代码

在 pages 下的 index.wxss 文件里面设置样式

.view1{  height:500rpx;  width:100%;  background-color: red; } .view2{  height:300rpx;  width:80%;  background-color: green; } .view3{  height:100rpx;  width:50%;  background-color: yellow; }复制代码

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

你可能感兴趣的文章
用python 登录 ssh 与 sftp 通过证书登录系统
查看>>
tpcc的测试
查看>>
批处理延时启动的几个方法
查看>>
Struts 体系结构与工作原理(图) .
查看>>
vim + cscope + kscope
查看>>
[Android] android的消息队列机制
查看>>
Xampp中的apache,tomcat无法启动的问题
查看>>
Oracle中表被删除或数据被错误修改后的恢复方法
查看>>
常见TCP端口号
查看>>
请不要轻易使用 is_numberic 加入存在E字母
查看>>
linux下svn迁移
查看>>
android studio下NDK开发
查看>>
SpringBoot基础篇配置信息之配置刷新
查看>>
第十一天:find
查看>>
golang sync WaitGroup
查看>>
使用graphite和grafana进行应用程序监控
查看>>
github推送错误:已经有此代码,不允许覆盖的解决方法
查看>>
C#MysqlHelper
查看>>
SpringMVC Hello World 实例
查看>>
MySQL BETWEEN 用法
查看>>