大家好,这个包 react-native-snap-carousel 需要帮助。我想像这样实现它https://i.pinimg.com/originals/d5/6a/06/d56a06bffbd19494fc8596b984789e29.gif
用于轮播的代码
_renderItem=({ item, index})=>{
return (
<View style={{backgroundColor:'#fff',height:'80%',margin:'3%',elevation:2,justifyContent:'center',alignItems:'center'}}>
<Text style={{fontFamily:'Poppins-Regular',fontSize:15,fontWeight:'300',color:'#444'}}>{item}</Text>
</View>
);
}
<Carousel
data={this.state.packageList}
renderItem={this._renderItem}
/>
如何将这个对象数组作为数据传递给 Carousel 组件,
{"packageList": [{"amount": 300, "characterization": "A", "description": "Entry level package.", "durationType": "M", "isFree": "N", "name": "Basic Package", "packageId": 1, "status": "A", "type": 4}, {"amount": 500, "characterization": "A", "description": "Premium package allows real-time displaying of the services and caters larger client base. Valid for 3 months ", "durationType": "TM","isFree": "N", "name": "Premium", "packageId": 2, "status": "A", "type": 4}, {"amount": 700, "characterization": "A","description": "Provides larger client base and features.", "durationType": "SM","isFree": "N", "name": "Extra Premium ","packageId": 3,"status": "A","type": 4}]}