Javascript 中对象文本的动态键
2022-08-30 05:40:08
						好吧,所以我正在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和它们都影响了编译器。:+.
现在我相信(不确定),对象文本是在编译时创建的,而不是在运行时创建的,这意味着动态变量(如和串联)将不可用:( :(this.applicationPath
克服此类障碍的最佳方法是什么,而不必重写大量代码。
 
					 
				 
				    		 
				    		 
				    		