在下面的代码中,我希望访问 getEnvironment 函数返回的环境对象。我将如何在我的代码中的其他地方访问这个对象?
window.EXAMPLE = {
config : {
local: 'http://localhost:8888/example',
staging_v2: 'http://example.com/staging',
production: 'http://example.com',
image_path: '/images/',
},
getEnvironment : function () {
if (window.location.href.indexOf(EXAMPLE.config.local) > -1) {
var environment = {
path : EXAMPLE.config.local + EXAMPLE.config.image_path,
}
return environment;
}
if (window.location.href.indexOf(EXAMPLE.config.staging_v2) > -1) {
var environment = {
path : EXAMPLE.config.staging_v2 + EXAMPLE.config.image_path,
}
return environment;
}
if (window.location.href.indexOf(EXAMPLE.config.production) > -1) {
var environment = {
path : EXAMPLE.config.production + EXAMPLE.config.image_path,
}
return environment;
}
},
}