您的位置:首页 > 其它

Ant Design Pro学习小结

2018-09-10 11:59 351 查看

在models的effects中直接用setTimeout函数会报错,例如以下错误写法:

[code]effects: {
*update({ payload }, { call, put }) {
const response = yield call(update, payload);
if (response.status == "success") {
message.success('成功!');
setTimeout(()=>{
yield put(routerRedux.push(`/xxx/xxx`));
},2000)
}
}
}

解决方案:就是在这个modal自定义一个方法,并在effects里调用settimeout方法

[code]const delay = (ms) => new Promise((resolve) => {
setTimeout(resolve, ms);
});

export default {
namespace: 'aa',
state: {},
effects: {
*update({ payload }, { call, put }) {
const response = yield call(update, payload);
if (response.status == "success") {
message.success('成功!');
setTimeout(()=>{
yield put(routerRedux.push(`/xxx/xxx`));
},2000)
}
}
},
reducers: {},
};

 

阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: