我不太擅长 JavaScript。我正在尝试编写一个可用于即时设置设置的构建配置类。这个想法是传递要运行的环境,然后正确设置变量。我有以下内容:
function BuildConfig(){
this.build = 'html5';
this.server = 'http://someurl',
this.nfc = true,
this.barcode = true,
this.scheduler = true,
this.getConfig = function(buildType){
switch(buildType)
{
case "ios":
this.build = 'ios';
this.server = 'http://someurl';
this.nfc = true;
this.barcode = false;
this.scheduler = false;
break;
case "android":
this.build = 'android';
this.server = 'http://someurl';
this.nfc = false;
this.barcode = true;
this.scheduler = false;
break;
case "websiteanonymous":
this.build = 'websiteanonymous';
this.server = 'http://someurl';
this.nfc = true;
this.barcode = false;
this.scheduler = true;
break;
case "website":
this.build = 'website';
this.server = 'http://someurl';
this.nfc = true;
this.barcode = true;
this.scheduler = false;
break;
default:
}
};
};
这看起来好吗?可以做任何改进吗?
谢谢