Javascript 在本机android上找不到变量
所以我对react native是个新手,我刚刚开始构建一个学习应用程序。这里是代码 App.jsJavascript 在本机android上找不到变量,javascript,android,reactjs,react-native,Javascript,Android,Reactjs,React Native,所以我对react native是个新手,我刚刚开始构建一个学习应用程序。这里是代码 App.js import React from "react"; import { StyleSheet, Text, View, Button } from "react-native"; import FetchLocation from "./components/FetchLocation"; export default class App extends React.Component {
import React from "react";
import { StyleSheet, Text, View, Button } from "react-native";
import FetchLocation from "./components/FetchLocation";
export default class App extends React.Component {
getUserLocationHandler = () => {
}
render() {
return (
<View style={styles.container}>
<FetchLocation onGetLocation={this.getUserLocationHandler}/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center"
}
});
import React from 'react';
import {Button} from 'react-native';
const fetchlocation = props => {
return(
<Button title="Get Location" onPress={props.onGetLocation} />
);
};
export default fetchLocation;
从“React”导入React;
从“react native”导入{样式表、文本、视图、按钮};
从“/components/FetchLocation”导入FetchLocation;
导出默认类App扩展React.Component{
getUserLocationHandler=()=>{
}
render(){
返回(
);
}
}
const styles=StyleSheet.create({
容器:{
弹性:1,
背景颜色:“fff”,
对齐项目:“中心”,
为内容辩护:“中心”
}
});
FetchLocation.js
import React from "react";
import { StyleSheet, Text, View, Button } from "react-native";
import FetchLocation from "./components/FetchLocation";
export default class App extends React.Component {
getUserLocationHandler = () => {
}
render() {
return (
<View style={styles.container}>
<FetchLocation onGetLocation={this.getUserLocationHandler}/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center"
}
});
import React from 'react';
import {Button} from 'react-native';
const fetchlocation = props => {
return(
<Button title="Get Location" onPress={props.onGetLocation} />
);
};
export default fetchLocation;
从“React”导入React;
从“react native”导入{Button};
const fetchlocation=props=>{
返回(
);
};
导出默认位置;
这是一张照片
这是我手机上出现错误的原因
我不认为这是一个复杂的问题,但它确实让我感到沮丧。
谢谢您在
fetchlocation.js
文件中拼错了fetchlocation
。它应该用大写字母L
。没关系,我们每个人都会这样。我投票决定结束这个问题,因为它只是一个小小的打字错误,但如果你愿意,你也可以删除这个问题。