
[英]React Native program returns “Unable to resolve ”srcscreensComponentsScreenListScreen“ from ”App.js"
[英]Unable to resolve module from App.js - React Native
我很安静,没有反应,我知道这很愚蠢,但我真的看不到。
我收到以下错误:无法从“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>
);
}
请检查 app.js 文件中的文件夹顺序/
不知道为什么,但是 react 对我如何实现这个脚本有问题,我把它改成下面的方式,它似乎工作正常。
import React from "react";
import { Text, StyleSheet, Platform } from "react-native";
function AppText({ children, style }) {
return <Text style={[styles.text, style]}>{children}</Text>;
}
const styles = StyleSheet.create({
text: {
fontSize: 18,
fontFamily: Platform.OS === "android" ? "Roboto" : "Avenir",
},
});
export default AppText;
最好检查屏幕文件必须在核心项目文件夹中..我犯了一个错误现在我把它整理出来
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.