一、navigator 跳转到tab页
<navigator url="/pages/index/index" open-type="switchTab">跳到tab页</navigator>
二、封装uni.request
根目录新建utils 文件夹->
新建api.js
三、给函数传一个回调函数作为形参
async getGoodsList(callBack){
const res = await this.$http({
url:'/api/getgoods?pageindex=' + this.pageindex
})
this.goods = [...this.goods, ...res.data.message];
// 所以这样写,来判断是否有callBack这个参数
callBack && callBack()
}
//有的地方调用没有传回调函数
this.getGoodsList();
// 有的地方有回调函数
setTimeout(()=>{
this.getGoodsList(()=>{
uni.stopPullDownRefresh();
});
},1000)