我想点击其中一个数据列表,并在id与我们在React Native中点击的内容匹配时更改绿色。 所以,如果我在id 1中单击callCircleButton而只是在id 1中单击更改带有名称的图标
关注我的代码:
constructor(props) {
super(props);
this.state = {
statusButton: true,
dataList: [
{id: 1, name: 'te1'},
{id: 2, name: 'test2'},
]
}
callCircleButton(){
if(this.state.statusButton == true){
this.setState({statusButton: false})
}else{
this.setState({statusButton: true})
}
}
render() {
return(
{this.state.dataList.map((data, i) => {
return (
<View style={{flex:1, flexDirection: 'row'}}>
<Text>data.name</Text>
<TouchableOpacity onPress={() => this.callCircleButton()}>
{ this.state.statusButton ?
<Icon active size={25} name='panorama-fish-eye' style={{marginRight:10, color: 'green'}}/>
:
<Icon active size={25} name='lens' style={{marginRight:10, color: 'white'}}/>
}
</TouchableOpacity>
</View>
)
})}
)
}
答案 0 :(得分:0)
单击时将活动按钮的ID设置为状态,并检查循环中的状态值。例如:
127.0.0.1 5432 <nil>
::1 2345 <nil>
localhost 1234 <nil>
答案 1 :(得分:0)
更改您的json数据结构。
insert into customer_price_list
(customer_price_id, customer_account_id, product_id, currency_id, customer_price, source)
select 0, customer_account_id, :product_id, :currency_id, :price, 'TRADE_DEFAULT' from customer_account
ON DUPLICATE KEY UPDATE customer_price=customer_price;