【发布时间】:2020-11-25 18:57:39
【问题描述】:
我对反应很陌生,我知道这很愚蠢,但我真的看不到。
我收到以下错误:无法从“App.js”解析“./app/components/Apptext”
import React, { Component } from 'react';
import { Text,StyleSheet,Platform } from 'react-native';
function AppText ({children})
{
return <Text style = {styles.text}>{children}</Text>
}
const styles = StyleSheet.create({
text:{
color:"tomato",
...Platform.select({
ios:{
fontSize:20,
fontFamily:"Avenir"
},
android:{
fontSize:18,
fontFamily:"Roboto"
}
})
},
})
export default AppText;
以上是我的 AppText 脚本
这是 app.js
import { StatusBar } from 'expo-status-bar';
import React, { Fragment } from 'react';
import {Dimensions ,SafeAreaView, StyleSheet,TouchableWithoutFeedback,Alert, Text, View ,Image, Button,Platform, BackHandler} from 'react-native';
import{ useDimensions,useDeviceOrientation } from '@react-native-community/hooks';
import WelcomeScreen from './app/screens/WelcomeScreen';
import AppText from './app/components/Apptext';
export default function App() {
return (
<View style ={{flex:1,justifyContent:"center",alignItems:"center",}}>
<AppText>I like react</AppText>
</View>
);
}
【问题讨论】:
-
AppText.js 文件是否在应用文件夹内的组件文件夹内?
-
@ShamarYarde 是的!
-
您是否尝试过重新加载应用程序或清理缓存:stackoverflow.com/a/41049449/8121551 或 medium.com/@abhisheknalwaya/…?模拟器可能正在使用以前的构建,它正在寻找错误的目录。
标签: javascript reactjs react-native