Javascript 反应本机,不能包含子级
我正在尝试在我的应用程序中添加一个徽标/图片。我已经在使用BackgroundImage,所以我想把它放在背景上。检查下面的代码。请帮我弄清楚Javascript 反应本机,不能包含子级,javascript,react-native,Javascript,React Native,我正在尝试在我的应用程序中添加一个徽标/图片。我已经在使用BackgroundImage,所以我想把它放在背景上。检查下面的代码。请帮我弄清楚 import React from 'react'; import { StyleSheet, Text, View, ImageBackground, Image } from 'react-native'; export default class App extends React.Component { render() { ret
import React from 'react';
import { StyleSheet, Text, View, ImageBackground, Image } from 'react-native';
export default class App extends React.Component {
render() {
return (
<ImageBackground source={require('./app/img/baky.jpeg')} style={styles.container}>
<View style={styles.inner}>
<Image source={require('./app/img/logo.png')} style={styles.logo}> </Image>
<Text style={styles.txt}> Hello!!!! </Text>
</View>
</ImageBackground>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
inner: {
padding: '10%',
justifyContent: 'center',
flexDirection: 'row',
width: '100%',
height: '100%',
backgroundColor: 'rgba(255, 255, 255, .7)'
},
logo: {
width: 50,
height: 50
},
txt: {
color: 'black',
}
});
只需更改为“打开”和“关闭”标记之间有一个空格。空白是一个元素文本节点。让它自动关闭@rhemon我刚刚删除了开始和结束标记之间的空间,它成功了!谢谢