-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
修改Controller中app的挂载说明 #3019
修改Controller中app的挂载说明 #3019
Conversation
- [Controller 文件](./controller.md) ```js // app/controller/user.js class UserController extends Controller { async fetch() { this.ctx.body = app.cache.get(this.ctx.query.id); } } ``` 经测试,无法直接在controller中使用app对象,只能够使用this.app
Codecov Report
@@ Coverage Diff @@
## master #3019 +/- ##
=======================================
Coverage 99.75% 99.75%
=======================================
Files 29 29
Lines 831 831
=======================================
Hits 829 829
Misses 2 2 Continue to review full report at Codecov.
|
可以改成 this.ctx.app |
@@ -51,17 +51,6 @@ Application 对象几乎可以在编写应用时的任何一个地方获取到 | |||
}; | |||
``` | |||
|
|||
- [Controller 文件](./controller.md) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是否误删除了?
// app/controller/user.js | ||
class UserController extends Controller { | ||
async fetch() { | ||
this.ctx.body = app.cache.get(this.ctx.query.id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里稍微有点问题,应该是 this.app.cache
This will be merged at: #3029 |
Controller 文件
经测试,无法直接在controller中使用app对象,只能够使用this.app
Checklist
npm test
passesAffected core subsystem(s)
Description of change