小程序列表切换较快,不同列表数据重复加载,这个问题怎么解决?
[图片] //快速切换头部,列表2的数据,可能会追加到列表1中,列表1的数据没来的及清空。 [代码]//头部切换[代码][代码] [代码][代码]onNavBar(e) {[代码][代码] [代码][代码]let navIndex = e.detail.setIndex;[代码][代码] [代码][代码]this[代码][代码].setData({ navIndex, showScreen: [代码][代码]false[代码][代码], page: 1, list: [], hasMore: [代码][代码]null[代码] [代码]});[代码][代码] [代码][代码]this[代码][代码].getOrderList();[代码][代码] [代码][代码]},[代码] [代码]//查询用工单审批列表[代码][代码] [代码][代码]getOrderList() {[代码][代码] [代码][代码]let reqData = {};[代码][代码] [代码][代码]let lock = [代码][代码]this[代码][代码].data.lock;[代码][代码] [代码][代码]if[代码] [代码](lock) {[代码][代码] [代码][代码]return[代码][代码];[代码][代码] [代码][代码]}[代码][代码] [代码][代码]reqData.page = [代码][代码]this[代码][代码].data.page;[代码][代码] [代码][代码]reqData.status = [代码][代码]this[代码][代码].data.navIndex;[代码][代码] [代码][代码]if[代码] [代码]([代码][代码]this[代码][代码].data.cdIds) {[代码][代码] [代码][代码]reqData.cdIds = [代码][代码]this[代码][代码].data.cdIds;[代码][代码] [代码][代码]}[代码] [代码] [代码][代码]this[代码][代码].setData({ pageState: [代码][代码]'frame'[代码][代码], lock: [代码][代码]true[代码] [代码]})[代码][代码] [代码][代码]orderModel.getList(reqData).then(res => {[代码][代码] [代码][代码]const tempArray = [代码][代码]this[代码][代码].data.list.concat(res.resultData.records);[代码][代码] [代码][代码]const dataState = tempArray.length > 0 ? [代码][代码]'finish'[代码] [代码]: [代码][代码]'empty'[代码][代码];[代码] [代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]lock: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]list: tempArray,[代码][代码] [代码][代码]pageState: dataState,[代码][代码] [代码][代码]hasMore: res.hasMore[代码][代码] [代码][代码]})[代码] [代码] [代码][代码]}).[代码][代码]catch[代码][代码](err => {[代码][代码] [代码][代码]this[代码][代码].setData({ pageState: [代码][代码]'error'[代码][代码], lock: [代码][代码]false[代码] [代码]})[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码]