解决方案:
输入框设置 always-embed
always-embed 解决 ios系统在input 聚焦时同层显示的问题
<input placeholder="请输入" always-embed="{{true}}"
value="{{waterTreatment}}" type="digit" bindblur="bindInputChange"></input>
微信小程序的滑动事件是通过bindtouchmove实现的,通过比较滑动事件前后的坐标判断滑动方向,微信小程序通过三个事件共同作用实现了触摸滑动事件,即 bingtouchstart、bindtouchmove 和 bindtouchend 事件。
WXML:
<view class='btn' bindtouchstart='touchStart' bindtouchmove='touchMove' bindtouchend='touchEnd'>
OK
</view>
JS:
data: {
touchS : [0,0],
touchE : [0,0]
},
touchStart: function(e){
// consolelog(etouches[0]pageX)
let sx = etouches[0]pageX
let sy = etouches[0]pageY
thisdatatouchS = [sx,sy]
},
touchMove: function(e){
let sx = etouches[0]pageX;
let sy = etouches[0]pageY;
thisdatatouchE = [sx, sy]
},
touchEnd: function(e){
let start = thisdatatouchS
let end = thisdatatouchE
consolelog(start)
consolelog(end)
if(start[0] < end[0] - 50){
consolelog('右滑')
}else if(start[0] > end[0] + 50){
consolelog('左滑')
}else{
consolelog('静止')
}
},
在 touchstart 时,监听到触摸开始时的 (x, y)位置;在 touchMove 方法中持续监听触摸点的位置(x, y),并保存在 data 中;在 touchEnd 方法中对开始的触摸位置和结束的触摸位置进行判断,如果移动距离大于 50 则判定为发生触摸滑动事件。
在上面示例中,当 X 轴方向的移动超过 50 时即判定为左滑或右滑,相应的也可以通过判断 Y 轴方向的滑动长度,来判断上滑或是下滑,由此实现触摸滑动的功能。
更多信息联系我的微
组件说明:
picker:
滚动选择器,现支持三种选择器,通过mode属性来区分,分别是普通选择器(mode = selector),时间选择器(mode = time),日期选择器(mode = date),默认是普通选择器。
以上就是关于微信小程序,输入框内容滑动文字跟着飘动全部的内容,包括:微信小程序,输入框内容滑动文字跟着飘动、手机小程序滑动返回是什么事件、微信小程序滑动选择器怎么实现等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)