微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

微信小程序-事件

normal;">小程序的"事件"挺有意思。看了说明文档后发现它的功能很全,事件可以向父节点传递,而且打印这个事件的信息很透明,调试起来应该非常方便。

什么是事件

事件是视图层到逻辑层的通讯方式。

事件可以将用户的行为反馈到逻辑层进行处理。

事件可以绑定在组件上,当达到触发事件,就会执行逻辑层中对应的事件处理函数

事件对象可以携带额外信息,如id, dataset, touches

事件的使用方式

在组件中绑定一个事件处理函数

如bindtap,当用户点击该组件的时候会在该页面对应的Page中找到相应的事件处理函数

rush:html;toolbar:false"> Click me! 

在相应的Page定义中写上相应的事件处理函数,参数是event。

rush:html;toolbar:false">Page({
tapName: function(event) {
console.log(event)
}
})

可以看到log出来的信息大致如下:

rush:html;toolbar:false">{
"type":"tap",
"timeStamp":895,
"target": {
"id": "tapTest",
"dataset":{
"hi":"WeChat"
}
},
"currentTarget":{
"id": "tapTest",
"dataset": {
"hi":"WeChat"
}
},
"detail": {
"x":53,
"y":14
},
"touches":[{
"identifier":0,
"pageX":53,
"pageY":14,
"clientX":53,
"clientY":14
}],
"changedtouches":[{
"identifier":0,
"pageX":53,
"pageY":14,
"clientX":53,
"clientY":14
}]
}

事件详解

事件分类

事件分为冒泡事件和非冒泡事件:

冒泡事件:当一个组件上的事件被触发后,该事件会向父节点传递。

非冒泡事件:当一个组件上的事件被触发后,该事件不会向父节点传递。

WXML的冒泡事件列表:

Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased;">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; background-color: rgb(246, 248, 249); border: none;" class="firstRow">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased;">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; border: none;">
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 6px 20px; border-width: initial; border-style: none; border-color: initial; font-weight: 400; color: rgb(141, 141, 141); text-align: left; height: 40px;">类型Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 6px 20px; border-width: initial; border-style: none; border-color: initial; font-weight: 400; color: rgb(141, 141, 141); text-align: left; height: 40px;">触发条件Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 6px 20px; border-width: initial; border-style: none; border-color: initial; font-weight: 400; color: rgb(141, 141, 141); text-align: left; height: 40px;">最低版本
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">touchstartBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">手指触摸动作开始Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; border-top: 1px solid rgb(231, 231, 235);">
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">touchmoveBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">手指触摸后移动Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; border-top: 1px solid rgb(231, 231, 235);">
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">touchcancelBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">手指触摸动作被打断,如来电提醒,弹窗Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; border-top: 1px solid rgb(231, 231, 235);">
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">touchendBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">手指触摸动作结束Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; border-top: 1px solid rgb(231, 231, 235);">
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">tapBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">手指触摸后马上离开Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; border-top: 1px solid rgb(231, 231, 235);">
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">longpressBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">手指触摸后,超过350ms再离开,如果指定了事件回调函数并触发了这个事件,tap事件将不被触发Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">注:除上表之外的其他组件自定义事件如无特殊申明都是非冒泡事件,如的submit事件,的input事件,的scroll事件,(详见各个)

事件绑定

事件绑定的写法同组件的属性,以 key、value 的形式。

key 以bind或catch开头,然后跟上事件的类型,如bindtap, catchtouchstart

value 是一个字符串,需要在对应的 Page 中定义同名的函数。不然当触发事件的时候会报错。

bind事件绑定不会阻止冒泡事件向上冒泡,catch事件绑定可以阻止冒泡事件向上冒泡。

如在下边这个例子中,点击 inner view 会先后触发handleTap3和handleTap2(因为tap事件会冒泡到 middle view,而 middle view 阻止了 tap 事件冒泡,不再向父节点传递),点击 middle view 会触发handleTap2,点击 outter view 会触发handleTap1。

outer view

middle view

inner view


事件对象

如无特殊说明,当组件触发事件时,逻辑层绑定该事件的处理函数会收到一个事件对象。

事件对象的属性列表:

Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">StringBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">事件类型Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; border-top: 1px solid rgb(231, 231, 235);">
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">ObjectBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">触发事件的组件的一些属性值集合Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; border-top: 1px solid rgb(231, 231, 235);">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">ObjectBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">额外的信息Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; orphans: 3; widows: 3; margin-top: 0px; margin-bottom: 0.85em; line-height: 2; color: rgb(51, 51, 51); letter-spacing: 0.2px; text-indent: 0px; white-space: normal;">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-weight: 700;">TouchEvent 触摸事件对象属性列表(继承 BaseEvent):

Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased;">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; background-color: rgb(246, 248, 249); border: none;" class="firstRow">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased;">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; border: none;">
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 6px 20px; border-width: initial; border-style: none; border-color: initial; font-weight: 400; color: rgb(141, 141, 141); text-align: left; height: 40px;">属性Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 6px 20px; border-width: initial; border-style: none; border-color: initial; font-weight: 400; color: rgb(141, 141, 141); text-align: left; height: 40px;">类型Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 6px 20px; border-width: initial; border-style: none; border-color: initial; font-weight: 400; color: rgb(141, 141, 141); text-align: left; height: 40px;">说明
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">ArrayBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">触摸事件,当前变化的触摸点信息的数组Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; orphans: 3; widows: 3; margin-top: 0px; margin-bottom: 0.85em; line-height: 2; color: rgb(51, 51, 51); letter-spacing: 0.2px; text-indent: 0px; white-space: normal;">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-weight: 700;">特殊事件: Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; direction: ltr; margin: 0px; padding: 0.2em; border: none; color: inherit; background-color: rgb(247, 247, 247);"> 中的触摸事件不可冒泡,所以没有 currentTarget。

代表事件的类型。

页面打开到触发事件所经过的毫秒数。

触发事件的源组件。

Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased;">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; background-color: rgb(246, 248, 249); border: none;" class="firstRow">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased;">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; border: none;">
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 6px 20px; border-width: initial; border-style: none; border-color: initial; font-weight: 400; color: rgb(141, 141, 141); text-align: left; height: 40px;">属性Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 6px 20px; border-width: initial; border-style: none; border-color: initial; font-weight: 400; color: rgb(141, 141, 141); text-align: left; height: 40px;">类型Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 6px 20px; border-width: initial; border-style: none; border-color: initial; font-weight: 400; color: rgb(141, 141, 141); text-align: left; height: 40px;">说明
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">idBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">StringBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">事件源组件的idBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; border-top: 1px solid rgb(231, 231, 235);">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">tagNameBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">StringBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">当前组件的类型Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; border-top: 1px solid rgb(231, 231, 235);">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">开头的自定义属性组成的集合

事件绑定的当前组件。

Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">ObjectBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">当前组件上由Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; direction: ltr; margin: 0px; padding: 0.2em; border: none; color: inherit; background-color: rgb(247, 247, 247);">data-开头的自定义属性组成的集合说明: target 和 currentTarget 可以参考上例中,点击 inner view 时,handleTap3 收到的事件对象 target 和 currentTarget 都是 inner,而 handleTap2 收到的事件对象 target 就是 inner,currentTarget 就是 middle。

dataset

在组件中可以定义数据,这些数据将会通过事件传递给 SERVICE。书写方式:以data-开头,多个单词由连字符-链接,不能有大写(大写会自动转成小写)如data-element-type,最终在 event.target.dataset 中会将连字符转成驼峰elementType。

示例:

rush:html;toolbar:false"> DataSet Test 
rush:html;toolbar:false">Page({
bindViewTap:function(event){
event.target.dataset.alphaBeta == 1 // - 会转为驼峰写法
event.target.dataset.alphabeta == 2 // 大写会转为小写
}
})

touches

Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased;">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; background-color: rgb(246, 248, 249); border: none;" class="firstRow">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased;">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; border: none;">
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 6px 20px; border-width: initial; border-style: none; border-color: initial; font-weight: 400; color: rgb(141, 141, 141); text-align: left; height: 40px;">属性Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 6px 20px; border-width: initial; border-style: none; border-color: initial; font-weight: 400; color: rgb(141, 141, 141); text-align: left; height: 40px;">类型Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 6px 20px; border-width: initial; border-style: none; border-color: initial; font-weight: 400; color: rgb(141, 141, 141); text-align: left; height: 40px;">说明
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">identifierBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">NumberBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">触摸点的标识符Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; border-top: 1px solid rgb(231, 231, 235);">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">pageX, pageYBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">NumberBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">距离文档左上角的距离,文档的左上角为原点 ,横向为X轴,纵向为Y轴Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; border-top: 1px solid rgb(231, 231, 235);">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">clientX, clientYBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">NumberBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial; word-break: break-all;" height="60">距离页面显示区域(屏幕除去导航条)左上角距离,横向为X轴,纵向为Y轴Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased;">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; background-color: rgb(246, 248, 249); border: none;" class="firstRow">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased;">Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; border: none;">
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 6px 20px; border-width: initial; border-style: none; border-color: initial; font-weight: 400; color: rgb(141, 141, 141); text-align: left; height: 40px;">属性Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 6px 20px; border-width: initial; border-style: none; border-color: initial; font-weight: 400; color: rgb(141, 141, 141); text-align: left; height: 40px;">类型Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 6px 20px; border-width: initial; border-style: none; border-color: initial; font-weight: 400; color: rgb(141, 141, 141); text-align: left; height: 40px;">说明Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 6px 20px; border-width: initial; border-style: none; border-color: initial; font-weight: 400; color: rgb(141, 141, 141); text-align: left; height: 40px;">特殊说明
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">identifierBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">NumberBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">触摸点的标识符Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; break-inside: avoid; border-top: 1px solid rgb(231, 231, 235);">
Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">x, yBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">NumberBox-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">距离 Canvas 左上角的距离,Canvas 的左上角为原点 ,横向为X轴,纵向为Y轴Box-sizing: border-Box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 12px 20px; border-width: initial; border-style: none; border-color: initial;" height="60">
touches">changedtouches

changedtouches 数据格式同 touches。 表示有变化的触摸点,如从无变有(touchstart),位置变化(touchmove),从有变无(touchend、touchcancel)。

自定义事件所携带的数据,如表单组件的提交事件会携带用户的输入,媒体的错误事件会携带错误信息,详见组件定义中各个事件的定义。

点击事件的detail 带有的 x, y 同 pageX, pageY 代表距离文档左上角的距离。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。