gpt4 book ai didi

reactjs - 类型错误 : Cannot read property 'width' of undefined when using ImageBackground

转载 作者:行者123 更新时间:2023-12-03 21:21:21 26 4
gpt4 key购买 nike

我正在使用 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com