前端BUG总结-按钮的loading状态
背景
- BUG1: 接口返回报错后,下一步按钮一直loading,需要恢复正常状态
- BUG2: 按钮的loading状态在报错后仍为loading状态,并未还原
代码
if (values.intlShippingType === "Calculated") {
params.intlShippingPolicyInfoServiceArr.forEach(item => {
if (item.shipToLocationType === null || item.shipToLocationType === undefined || item.shipToLocationType === "") {
message.warning("请选择收货地点");
flag = true
return false
if (item.shippingService === null || item.shippingService === undefined || item.shippingService === "") {
message.warning("请选择服务");
flag = true
return false
}
})
let arr = params.intlShippingPolicyInfoServiceArr;
var tempHash = {};
let initLength=arr.length;
let noRepeatLength = arr.reduce(function (item, next) {
tempHash[next.shipToLocationType] && (tempHash[next.shippingService + '_'+ next.shipToLocationType] == next.shippingService) ? "" : (tempHash[next.shipToLocationType] = true) && (tempHash[next.shippingService + '_'+next.shipToLocationType] = next.shippingService) && item.push(next);
return item
}, []).length;
if(initLength!==noRepeatLength){
message.warning("全球运输中收货和服务不能重复");
flag = true;
return false
}
}
if (flag) {
setTimeout(() => {
this.setState({
loading: false
});
}, 500)
return;
}