我正在使用Windows 10并正在运行Android 7.0设备。
我正在尝试通过地理位置使设备显示经纬度和当前位置的长状态-当用户按下按钮时。
我创建了一个按钮,并在用户单击该按钮时显示了一条警告消息-到目前为止,一切都很好。
然后我尝试添加获取当前位置,然后我的应用因错误而崩溃:
未定义不是对象(评估'_reactNative.Geolocation.getCurrentPosition')
这是我的代码:
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View,
Button,
Alert,
Geolocation
} from 'react-native';
const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' +
'Cmd+D or shake for dev menu',
android: 'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu',
});
export default class App extends Component {
render() {
return (
<View style={styles.container}>
<Button
onPress={() => {
var …
Run Code Online (Sandbox Code Playgroud) react-native ×1