我正在使用 ImageBackground 来自 React Native 的组件。但是,无论我选择什么样式,总是会显示相同的错误消息。代码如下所示:
render() {
return (
<ImageBackground
source={require('./common/Background_image.png')}
stlye={styles.backgroundStyle}
>
<Text>Some text here!!</Text>
</ImageBackground>
);
}
backgroundStyle: {
flex: 1,
width: null,
height: null,
resizeMode: 'cover'}
Image of the error here
react 原生版本:
react 原生cli:2.0.1
react 原生:0.55.4
关于这可能发生什么的任何想法?
最佳答案
你路过 stlye
但正确的语法应该是 style
<ImageBackground
source={require('./common/Background_image.png')}
style={styles.backgroundStyle}
>
<Text>Some text here!!</Text>
</ImageBackground>
关于reactjs - 类型错误 : Cannot read property 'width' of undefined when using ImageBackground,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53695534/