数码资讯
微信小程序监控手势滑动切换页面实例详解
微信小程序监控手势滑动切换页面实例详解 1。在相应的XML中,对手势的开始、滑动和结束进行监视。 2.js: 无功touchdot = 0; / /触摸的起源 var时间= 0;在执行时间附近滑动和滑动的时间记录小于1s。 var 页({ 数据:{…} }) 页({ 数据:{ … }, 启动/触摸事
选购提示
关注价格、性能、续航、售后和真实使用场景,理性比较后再下单。
微信小程序监控手势滑动切换页面实例详解
1。在相应的XML中,对手势的开始、滑动和结束进行监视。
2.js:
无功touchdot = 0; / /触摸的起源
var时间= 0;在执行时间附近滑动和滑动的时间记录小于1s。
var
页({
数据:{…}
})
页({
数据:{
…
},
启动/触摸事件
TouchStart:功能(e){
touchdot = e.touches { 0 }。pagex; / /得到触摸的起源
使用js定时器记录时间
区间= setInterval(){()函数(
时间+;
},100);
},
触摸/移动事件
touchmove:功能(e){
VaR touchmove = e.touches { 0 }。pagex;
console.log(touchmove:+ +touchdot touchmove:+ touchdot +diff:+(touchmove - touchdot));
向左滑动
如果(touchmove - touchdot - 40次<< = 10){
Wx.switchTab({
URL:左/左页/左页
});
}
幻灯片
如果(touchmove - touchdot,时间< 10 > = 40){
console.log('sliding右边的);
Wx.switchTab({
URL:…..右幻灯片页/右幻灯片页
});
}
},
触摸/结束事件
TouchEnd:功能(e){
ClearInterval(间隔); / /清除setInterval
时间= 0;
},
。
。
。
})
谢谢你的阅读。我希望你能帮助你,谢谢你对这个站的支持。
1。在相应的XML中,对手势的开始、滑动和结束进行监视。
2.js:
无功touchdot = 0; / /触摸的起源
var时间= 0;在执行时间附近滑动和滑动的时间记录小于1s。
var
页({
数据:{…}
})
页({
数据:{
…
},
启动/触摸事件
TouchStart:功能(e){
touchdot = e.touches { 0 }。pagex; / /得到触摸的起源
使用js定时器记录时间
区间= setInterval(){()函数(
时间+;
},100);
},
触摸/移动事件
touchmove:功能(e){
VaR touchmove = e.touches { 0 }。pagex;
console.log(touchmove:+ +touchdot touchmove:+ touchdot +diff:+(touchmove - touchdot));
向左滑动
如果(touchmove - touchdot - 40次<< = 10){
Wx.switchTab({
URL:左/左页/左页
});
}
幻灯片
如果(touchmove - touchdot,时间< 10 > = 40){
console.log('sliding右边的);
Wx.switchTab({
URL:…..右幻灯片页/右幻灯片页
});
}
},
触摸/结束事件
TouchEnd:功能(e){
ClearInterval(间隔); / /清除setInterval
时间= 0;
},
。
。
。
})
谢谢你的阅读。我希望你能帮助你,谢谢你对这个站的支持。
声明:本文内容用于数码产品信息整理与选购参考,具体价格、库存、售后政策以官方渠道和电商页面实时信息为准。