使用koa-router管理路由的时候,想在收到表单post请求后redirect到别的路由,但是使用this.redirect和router.redirect都无法跳转。请问正确的写法是什么
无效的代码:
router.post('/login', bodyParser, function* (next) {
// ...
this.redirect('/index');
});
使用koa-router管理路由的时候,想在收到表单post请求后redirect到别的路由,但是使用this.redirect和router.redirect都无法跳转。请问正确的写法是什么
无效的代码:
router.post('/login', bodyParser, function* (next) {
// ...
this.redirect('/index');
});
10 回答11.7k 阅读
2 回答3.2k 阅读✓ 已解决
4 回答2.2k 阅读✓ 已解决
3 回答2.1k 阅读✓ 已解决
3 回答1.2k 阅读✓ 已解决
3 回答868 阅读✓ 已解决
5 回答2.3k 阅读
koa-router 文档里写的方法,类似的还有 router.redirect
你也可以直接写进 this 里面,来符合你的习惯