1. this.ctx.request.body //获取post提交的数据
  2. this.ctx.request.url //获取get的url
  3. this.ctx.request.query //获取get传值
  4. this.ctx.status //设置状态码
  5. this.ctx.state //设置模板的全局变量

1.获取动态路由 this.ctx.parmas

  1. //配置动态路由
  2. router.get('/:id',controller.news.newslist)
  3. //获取动态路由
  4. class HomeController extends Controller {
  5. async index() {
  6. await this.ctx.render('index')
  7. console.log(this.ctx.params)
  8. }
  9. }
  10. module.exports = HomeController;