我正在使用FlatList,它可以正确显示所有内容。
但是,当我更新产品数量时,它只会增加总量,而FlatList的renderItem 不会发生任何变化。
当我按下加号按钮时,总金额会更改,但产品数量不会更改。
如何更新产品数量?更新总金额后FlatList,为什么不更改项目数量?
我的代码:-
constructor(props) {
super(props);
this.state = {
data:[
{id:4, productName:'Product 4', shortDescription:'shortDescription 4', qty:1, price:500 },
{id:5, productName:'Product 5', shortDescription:'shortDescription 5', qty:1, price:1000},
{id:6, productName:'Product 6', shortDescription:'shortDescription 6', qty:1, price:1000},
],
};
}
_addQty = (index) => {
var data = this.state.data;
data[index].qty = data[index].qty + 1;
this.setState(data:data);
}
_getTotalPrice = () => {
var total = 0;
for (var i = 0; i < this.state.data.length; …Run Code Online (Sandbox Code Playgroud) 功能覆盖
func willTransition(to newCollection: UITraitCollection, with coordinator: UIViewControllerTransitionCoordinator) { }
Run Code Online (Sandbox Code Playgroud)
我在iPad设备上构建和运行时没有触发,但它在移动设备上工作正常(iphone 5,6,7 ......).怎么解决这个?
提前致谢!!