收藏
回答

设备方向API中的interval参数不生效,始终是20ms

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug 设备方向 微信安卓客户端 8.0.6.1900 2.18.0
https://developers.weixin.qq.com/miniprogram/dev/api/device/motion/wx.startDeviceMotionListening.html
    wx.startDeviceMotionListening({interval:'ui',
      success(e) {
        wx.onDeviceMotionChange((res) => {
          if (res.alpha) {
            let timestamp = Date.now()
            console.log("motion时间戳",timestamp)
            let motion = res
            motion.timestamp = timestamp
            let time = new Date().toLocaleTimeString()
            motion.time = time
            let data = {
              type: "device",
              tag_id: app.globalData.tagId,
              data: {
                motion: motion
              }
            }
            // console.log("设备值",res)
            let count=that.data.sendCount+1
            if(that.data.sendCount%4==0){
              sendSocketMessage(data,app.globalData)
            }
            that.setLocationMakerDirection(res.alpha)
            // //console.log("罗盘", res.direction)
            that.setData({
              angle: res.alpha,
              sendCount:count
            })
          }
          // //console.log("设备方向", res.alpha)
        })
      }
    })
回答关注问题邀请回答
收藏
登录 后发表内容