weex如何获取手势方向?

使用v-on:swipe="onSwpie(item)"监听手势的变化,请问如何取得当前手势滑动方向。官方说在回调中可以获得:

以下属性可以在手势的回调中使用:

direction:仅在 swipe 手势中存在,返回滑动方向,返回值可能为 up, left, bottom, right。
changedTouches:一个数组,包含了当前手势的触摸点的运动轨迹

尝试未果,


GCT1015
浏览 865回答 2
2回答

慕少森

建议可以console.log打印出item,查看下信息

阿波罗的战车

场景:列表的cell向左滑动出现操作按钮。关键代码如下:&nbsp;<cell&nbsp;class="bui-cell"&nbsp;v-for="(item,index)&nbsp;in&nbsp;listData"&nbsp;v-on:swipe="onSwipe($event,item)"> ... </cell>注意这里不仅仅要用到swipe事件的回调,也需要给onSwipe传入列表数据,需要增加个$event,在这个对象里面才能够获取到回调属性。"onSwipe":function&nbsp;(event,item)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log(">>>>>>>>>>") &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log(event); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log(event.direction);}这样就可以根据获取到swipe的方向了。如果只是v-on:swipe="onSwipe()"也会有个event,但如果需要传入额外的参数,就得主动传个$event进去,vue里面的事件对象
打开App,查看更多内容
随时随地看视频慕课网APP