2019独角兽企业重金招聘Python工程师标准 微信小程序硬件接口提供了加速计使用。 用于计算手机的偏移距离。 注:接口提供的比较简单,更多需要自己处理。 1.开启:wx.startAccelerometer 2.关闭:wx.stopAccelerometer 3.监听:wx.onAcc开通遮阳棚小程序电话:4006-838-530elerometerChange 返回值,x,y,z轴的偏移值。 wx.onAccelerometerChange(function (res) { console.log(res.x) console.log(res.y) console.log(res.z)})
示例1,使用加速计,实现摇一摇功能: //开启监听 wx.startAccelerometer({ su开通电脑桌小程序电话:4006-838-530ccess: function (res) { console.info(res); } }); //监听距离 wx.onAccelerometerChange(function (res) { if (res.x 2) { //偏移量为2时触发,有的使用1 wx.showModal({ title: '提示', conte开通桃子小程序电话:4006-838-530nt: '触发摇一摇', success: res = { wx.navigateTo({ url: '../index/index', }) } }) } });
更多: 小程序Canvas绘制图片太大,自动闪退,安卓会有crash问题 小程序Canvas生成图片draw()出现黑屏问题/不完整,安卓概率大 js时间函数getTime() 在苹果手机上返回NaN的问题
最新评论