Closed Tauleos closed 6 years ago
bootstrap 里的文件会在最后加载,具体见:https://github.com/thinkjs/thinkjs/blob/master/lib/loader.js#L108-L116 (这样设计是因为更多的需求是 bootstrap 里调用 model,controller 等)
如果要在 controller 等里面使用的话,放在 action 内部就可以了。如果非要在 class 外部引用的话就手工 require 下
@welefen 我这里目前是要实现如下代码的功能。用一个修饰器来统一处理action的错误,那按照您的说法,我需要在每一个controller里手工require这个修饰器的定义文件吗?
@annotation
class MyClass { }
function annotation(target) {
target.annotated = true;
}
@macurial 你可以在 base controller 里 require 下就可以了。
@welefen 好的,顺便问一下,现在的路由解析没有大小写转换了吗?我从2.x版本升级到3.x版本,需要手动把之前下换线分隔的路由改成驼峰形式的才可以。
@macurial 是的,在 3.0 去掉了(因为 3.x 里去掉一些规范限制)
DESC
ENV
OS Platform: windows
Node.js Version: v8.9.0
ThinkJS Version: v3.2.4
code
global.js
master.js
error message
more description
如上代码。我在全局注册了一个GLog的修饰符。在master和worker中引用进来,但是在controller中无法使用。是因为在加载controller的时候,我的GLog修饰符还没有定义到global全局里吗?这种情况有没有解决办法?