小编And*_*han的帖子

在本机反应中未授予位置权限

我在寻找位置时遇到了一个小问题,这是我的代码

export default class  App extends React.Component{
  state = {
        location: null
    };

    findCoordinates = () => {
        Geolocation.getCurrentPosition(
            position => {
                const location = JSON.stringify(position);
                this.setState({ location });
            },
      error => Alert.alert(error.message),
      { enableHighAccuracy: true, timeout: 15000, maximumAge: 10000 }
    );
    };
  render(){
    return (
      <View style={styles.container}>
                <TouchableOpacity onPress={this.findCoordinates}>
                    <Text style={styles.welcome}>Find My Coords?</Text>
                    <Text>Location: {this.state.location}</Text>
                </TouchableOpacity>
            </View>
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

他们显示未授予位置许可

react-native react-native-android

1
推荐指数
2
解决办法
5228
查看次数

标签 统计

react-native ×1

react-native-android ×1