1. 程式人生 > >觸屏時間控制

觸屏時間控制

tom tex con bind order ear fix tint cti

// pages/youxi/dian1.js Page({
/** * 頁面的初始數據 */ data: { bian: 0, zhuan: 0, textTure: ‘touchstart‘ }, shiFN: function (e) { let that = this; let n = 0; // 判斷是開始還是結束的參數 let textTure = e.type; that.setData({ textTure: textTure }) if (textTure == ‘touchstart‘) { let lovetime = setInterval(function () { n += 0.5;
if (that.data.textTure == ‘touchend‘) { clearInterval(lovetime); } console.log(n); that.setData({ bian: n }) }, 500)
} },
}) <view class=‘yx-box‘> <view class=‘yx-content‘> <view>{{bian}}</view> </view> <view class=‘bt flexca‘> <view class=‘bt-item‘ bindtouchend=‘shiFN‘ bindtouchstart=‘shiFN‘></view> </view> </view> page { width: 100%; height: 100%; }
.yx-box { width: 100%; height: 100%; ">red; position: relative; padding-bottom: 60px; }
.bt { width: 100%; height: 60px; position: fixed; left: 0; bottom: 0; }
.bt-item { width: 45px; height: 45px; ">blue; border-radius: 50%; }
.yx-content { width: 100%; height: 100%; ">gray; }

觸屏時間控制