在写代码时,看到前辈在发送网络请求时的一个很好的习惯,在请求,数据处理中会进行showloading,大大增大了加载过程中的交互,代码如下:
JAVASCRIPTrequestAssessmentList() {
uni.showLoading({
title: this.lang['global']['loading-text']
});
getAssessmentList()
.then((res) => {
if (res.errorMsg == 'Success') {
// 过滤掉剩余次数为0的卷子
this.paperList = res.assessment.filter((i) => {
const num = i.numberOfRetakesPossible;
return num || num != 0;
});
// this.paperList = res.assessment
/* this.paperList.push({
kindName:"化妆品",
brandNames:["a","b","c"],
seriesName:["32342","23543","5436"]
}) */
} else {
uni.showToast({
title: res.errorMsg,
duration: 2000
});
}
})
.finally(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
});
},