好的,所以我正在 Nodes 中处理一个项目,并且我遇到了对象文字中的键的一个小问题,我有以下设置:
var required = {
    directories : {
        this.applicationPath                    : "Application " + this.application + " does not exists",
        this.applicationPath + "/configs"       : "Application config folder does not exists",
        this.applicationPath + "/controllers"   : "Application controllers folder does not exists",
        this.applicationPath + "/public"        : "Application public folder does not exists",
        this.applicationPath + "/views"         : "Application views folder does not exists"
    },
    files : {
        this.applicationPath + "/init.js"               : "Application init.js file does not exists",
        this.applicationPath + "/controllers/index.js"  : "Application index.js controller file does not exists",
        this.applicationPath + "/configs/application.js": "Application configs/application.js file does not exists",
        this.applicationPath + "/configs/server.js"     : "Application configs/server.js file does not exists"
    }
}
好吧,你们中的许多人会看到这个并认为它看起来不错,但是编译器一直告诉我我缺少一个:(冒号),我没有,似乎+or 和 the.都影响编译器。
现在我相信(不确定),对象文字是在编译时创建的,而不是在运行时创建的,这意味着动态变量(例如this.applicationPath和 连接)将不可用:( :(
在不必重写大量代码的情况下克服这样的障碍的最佳方法是什么?