# startAccelerometer ^6.8

加速计监听

# 请求参数

  • N/A

# 接口调用示例

    this.$bridge
    .startAccelerometer()
    .then(res => {    
        this.$alert(res)
    })
    .catch(err => {
        this.$toast(err)
    })

    // bridge v0.2.3起支持回调函数,回调函数可触发多次
    this.$bridge
    .startAccelerometer(
        res => {    
            this.$alert(res)
        }, 
        err => {
            this.$toast(err)
        }
    )

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

# 返回参数

  • 成功时返回
Prop Type Comment
code Number 0
x Number -
y Number -
z Number -
  • 失败时返回(api为空或者没有)
Prop Type Value
code Number -1
msg String 失败
Prop Type Value
code Number -8
msg String 不支持

# 返回示例


{
    "code": 0,
    "x": 0.0782139253616333,
    "y": -0.037050821185112,
    "z": -0.975174933969972
}

1
2
3
4
5
6
7
8
Last Updated: 10/27/2022, 4:12:24 PM