thinkjs / thinkjs

Use full ES2015+ features to develop Node.js applications, Support TypeScript.
https://thinkjs.org/
MIT License
5.31k stars 616 forks source link

3.X框架扩展的问题? #729

Closed mxh861001 closed 7 years ago

mxh861001 commented 7 years ago

DESC

多模块项目,扩展了ctx对象,控制器里访问的时候报错如下:

TypeError: _this.ctx.tests is not a function

src/extend/context.js module.exports = { tests(str) { return str + '========'; } }

XX/controller/base.js console.warn(this.ctx.tests('aa'));

ENV

Platform: windows

Node.js Version: 6.11.1

ThinkJS Version: 3.X

welefen commented 7 years ago

放在 src/common/extend/ 下

mxh861001 commented 7 years ago

@welefen OK了,建议更新文档

welefen commented 7 years ago

@mxh861001 已经更新文档,https://thinkjs.org/zh-cn/doc/3.0/extend.html#toc-662