标签:ret 返回 call syn set sync object run async
export async function sleep({res,time}){
function run(){
return new Promise((resolve,reject)=>{
setTimeout(()=>{
resolve(res)
},time)
})
}
return await run()
};
/*
sleep : 模拟异步返回请求结果,当接口 不能直接调用的时候, 导入这个函数并调用
@params
res: object {code:0,data:'data',msg:'ok'}
time: time-ms 毫秒 3000 200
@use:
const res = yield call(sleep,{res:{
code:0,msg:"测试成功"
},time:3000})
*/
标签:ret 返回 call syn set sync object run async
原文地址:https://www.cnblogs.com/chengyunshen/p/12394042.html