使用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.1k 阅读
6 回答3k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3k 阅读✓ 已解决
2 回答2.6k 阅读✓ 已解决
4 回答2.4k 阅读✓ 已解决
3 回答2.3k 阅读✓ 已解决
koa-router 文档里写的方法,类似的还有 router.redirect
你也可以直接写进 this 里面,来符合你的习惯