我想在我的react-native 应用程序中使用背景图像,
但如果图像为loaded from asset bundle,则不起作用
var styles = StyleSheet.create({
bgImage: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'stretch',
resizeMode: 'stretch',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
}
});
<Image source={require('image!background')} style={styles.bgImage}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
</Image>
看起来是这样的:
但是,它适用于远程图像,通过source={{uri: 'background-image-uri'}}
: