mirror of
https://github.com/eggjs/egg.git
synced 2024-12-04 07:14:30 +00:00
43 lines
1.0 KiB
Plaintext
43 lines
1.0 KiB
Plaintext
/**
|
||
* 继承 koa 的 Context
|
||
* @class Context
|
||
* @see http://koajs.com/#context
|
||
*/
|
||
|
||
/**
|
||
* 实现页面跳转
|
||
* @see Response#redirect
|
||
* @method Context#redirect
|
||
* @param {String} url 需要跳转的地址
|
||
*/
|
||
|
||
/**
|
||
* 开启 {@link Rest} 功能后,将会有 `this.params` 对象
|
||
* @member {Object} Context#params
|
||
* @example
|
||
* ##### ctx.params.id {String}
|
||
*
|
||
* 资源 id,如 `GET /api/users/1` => `'1'`
|
||
*
|
||
* ##### ctx.params.ids {Array<String>}
|
||
*
|
||
* 一组资源 id,如 `GET /api/users/1,2,3` => `['1', '2', '3']`
|
||
*
|
||
* ##### ctx.params.fields {Array<String>}
|
||
*
|
||
* 期待返回的资源字段,如 `GET /api/users/1?fields=name,title` => `['name', 'title']`.
|
||
* 即使应用 Controller 实现返回了全部字段,[REST] 处理器会根据 `fields` 筛选只需要的字段。
|
||
*
|
||
* ##### ctx.params.data {Object}
|
||
*
|
||
* 请求数据对象
|
||
*
|
||
* ##### ctx.params.page {Number}
|
||
*
|
||
* 分页码,如 `GET /api/users?page=10` => `10`
|
||
*
|
||
* ##### ctx.params.per_page {Number}
|
||
*
|
||
* 每页资源数目,如 `GET /api/users?per_page=20` => `20`
|
||
*/
|