英文:
JSX expressions must have one parent element.ts(2657)
问题
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
export default function App() {
return (
<View style={styles.container}>
<Text>打开 App.js 开始你的应用开发!</Text>
<StatusBar style="auto" />
</View>
<View>
<Text>ffff</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'red',
},
});
英文:
i am using React Native, i am freshman there , what is the problem here: mistake is there
i am using React Native, i am freshman there , what is the problem here: mistake is there
i am using React Native, i am freshman there , what is the problem here: mistake is there
i am using React Native, i am freshman there , what is the problem here: mistake is there
i am using React Native, i am freshman there , what is the problem here: mistake is there
i am using React Native, i am freshman there , what is the problem here: mistake is there
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
export default function App() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
<StatusBar style="auto" />
</View>
<View >
<Text>ffff</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'red',
},
});
答案1
得分: 0
import React from 'react';
import { StyleSheet, Text, View, StatusBar } from 'react-native';
export default function App() {
return (
<>
<StatusBar barStyle="dark-content"/>
<View style={styles.container}>
<Text>打开 App.js 开始开发您的应用!</Text>
</View>
<View >
<Text>ffff</Text>
</View>
</>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'red',
},
});
英文:
You've to wrap up your content in a parent section or view like this:
import React from 'react';
import { StyleSheet, Text, View, StatusBar } from 'react-native';
export default function App() {
return (
<>
<StatusBar barStyle="dark-content"/>
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
</View>
<View >
<Text>ffff</Text>
</View>
</>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'red',
},
});
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论