Javascript react native snap carousel返回“;无法读取属性';concat&x27;“未定义”的定义;当我使用RenderTime时
我正在学习React-Native并在我的项目中使用React-Native snap carousel。 我想显示一些图像,但出现错误Javascript react native snap carousel返回“;无法读取属性';concat&x27;“未定义”的定义;当我使用RenderTime时,javascript,reactjs,react-native,react-native-android,react-native-snap-carousel,Javascript,Reactjs,React Native,React Native Android,React Native Snap Carousel,我正在学习React-Native并在我的项目中使用React-Native snap carousel。 我想显示一些图像,但出现错误无法读取未定义的属性“concat” 这是我的密码 const HomePage = (props) => { let imageList = ['../images/index-bg.png', '../images/down.png']; const renderImage = ({ item, index }) => {
无法读取未定义的属性“concat”
这是我的密码
const HomePage = (props) => {
let imageList = ['../images/index-bg.png', '../images/down.png'];
const renderImage = ({ item, index }) => {
return (
<View>
<Image source={require(item)}></Image>
</View>
)
};
return (
<View>
<Carousel
loop={true}
autoplay={true}
data={imageList}
renderItem={renderImage}
sliderWidth={pxToDp(50)}
itemWidth={pxToDp(100)}
/>
</View>
)
}
const主页=(道具)=>{
让imageList=['../images/index bg.png','../images/down.png'];
常量渲染年龄=({item,index})=>{
返回(
)
};
返回(
)
}
如果我改变
<View>
<Image source={require(item)}></Image>
</View>
到
···
它工作得很好
我希望它能像[用法](https://github.com/archriss/react-native-snap-carousel)但它不起作用。
你试过这个吗
let imageList = [require('../images/index-bg.png'), require('../images/down.png')];
然后
<View>
<Image source={item}></Image>
</View>
必须在运行前定义RN中图像所需的源
让我知道它是否有效 它工作得很好!谢谢,这真的帮了我大忙!如果你愿意,接受答案,这样别人也会很容易得到帮助
<View>
<Image source={item}></Image>
</View>