我有这个SwipeList,我希望当我按下此按钮(TouchableOpacity style = {styles.rowBack})时,要删除整行。
<SwipeListView
disableRightSwipe={true}
useFlatList
data={[{key: 'a'}, {key: 'b'}, {key: 'c'}, {key: 'd'}]}
renderItem={ (data, rowMap) => (
<View style={styles.rowFront}>
<ProductComponent type={'car'} />
<SumSustProduct />
</View>
)}
renderHiddenItem={ (data, rowMap) => (
<TouchableOpacity style={styles.rowBack}>
<View style={styles.closeButCar}>
<Image source={require('../../assets/images/closeBut.png')} resizeMode='contain'/>
</View>
</TouchableOpacity>
)}
leftOpenValue={75}
rightOpenValue={-75}
/>
答案 0 :(得分:0)
将数据集设置为组件状态,并将swipelistview属性设置为data={this.state.data}
,然后建议对数据使用拼接,以删除所需索引处的项,然后删除this.setState({ data: splicedData})
。这是了解拼接https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice