Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

stonemakers
Copy link

  • Controller 文件

    // app/controller/user.js
    class UserController extends Controller {
      async fetch() {
        this.ctx.body = app.cache.get(this.ctx.query.id);
      }
    }

经测试,无法直接在controller中使用app对象,只能够使用this.app

Checklist
  • npm test passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)
Description of change

- [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
@atian25 atian25 mentioned this pull request Sep 19, 2018
4 tasks
@codecov
Copy link

codecov bot commented Sep 19, 2018

Codecov Report

Merging #3019 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e3ffcbe...8a27d9c. Read the comment docs.

@popomore
Copy link
Member

可以改成 this.ctx.app

@@ -51,17 +51,6 @@ Application 对象几乎可以在编写应用时的任何一个地方获取到
};
```

- [Controller 文件](./controller.md)

Copy link

@ghost ghost Sep 20, 2018

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里稍微有点问题,应该是 this.app.cache

@ghost ghost mentioned this pull request Sep 20, 2018
4 tasks
@ghost
Copy link

ghost commented Sep 20, 2018

This will be merged at: #3029

@ghost ghost closed this Sep 20, 2018
ghost pushed a commit that referenced this pull request Sep 21, 2018
1) 'app....' should be 'this.app....'.
2) 4 levels instead of 5 for each logger instance.

Ref:
1) #3019
2) #3018
popomore pushed a commit that referenced this pull request Sep 21, 2018
doc (objects.md): Fix number and code errors (#3029)

1) 'app....' should be 'this.app....'.
2) 4 levels instead of 5 for each logger instance.

Ref:
1) #3019
2) #3018
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants