使用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');
});
13 回答12.8k 阅读
7 回答2k 阅读
3 回答2.6k 阅读✓ 已解决
3 回答1.1k 阅读✓ 已解决
2 回答1.2k 阅读✓ 已解决
6 回答927 阅读✓ 已解决
6 回答1.1k 阅读
koa-router 文档里写的方法,类似的还有 router.redirect
你也可以直接写进 this 里面,来符合你的习惯