uni请求中showloading显示

在写代码时,看到前辈在发送网络请求时的一个很好的习惯,在请求,数据处理中会进行showloading,大大增大了加载过程中的交互,代码如下:

JAVASCRIPT
requestAssessmentList() { 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(); }); },
【END】

版权声明:本博客所有文章除声明转载外,均采用 BY-NC-SA 3.0 许可协议。转载请注明来自 Wblog

阅读 15 | 发布于 2024-10-18
暂无评论