React Web中的WC3传感器

问题描述 投票:0回答:1

[我正在尝试让W3C Sensors API在我的React Web App(不是React Native)中运行,基本上我找不到任何可靠的文档来使其能够使用javascript运行,这是我到目前为止生成的代码:] >

  import React, { Component } from "react";

  export default class Postion extends Component {
  state = {
    message: "not supported",
  };
  componentDidMount() {
    this.test();
  }

  test(){
    if(window.Accelerometer){
        this.setState({message:"supported"})
    }
  }

  render() {
    return <div>{this.state.message}</div>;
  }
}

它到目前为止在我尝试过的所有桌面浏览器上都显示“受支持”,而在我尝试过的所有移动浏览器上均显示“不支持”,所以我的问题是:如何使用传感器API(特别是在移动浏览器上)从加速度计获取数据?我什至可以完成?谢谢。

我正在尝试使W3C Sensors API在我的React Web App(不是React Native)中运行,基本上我找不到任何可靠的文档来使其能够使用javascript正常工作,这是我的代码...

reactjs w3c w3c-geolocation
1个回答
0
投票

我还没有用过。但是MDN上总是有不错的文档:

© www.soinside.com 2019 - 2024. All rights reserved.