我有一个用于配置目的的类,如下所示。
let urlsForDevelopement:any = {
serviceName : "https://localhost:44300/breeze/data",
signalrAddress : 'https://localhost:44300'
};
let urlsForProduction: any = {
serviceName: "https://Prodhost:44300/breeze/data",
signalrAddress: 'https://Prodhost:44300'
};
var Urls: any;
if (window.location.hostname === 'localhost') {
Urls = urlsForDevelopement;
}
else {
Urls = urlsForProduction;
}
export default Urls;
确实有效。但有没有办法把它写成一个类?或者也许是一种更好的写作方式?
在c#中,我将使用预处理器if
语句。
答案 0 :(得分:1)
在c#中,我会使用预处理器if语句。
我也愿意。 TypeScript不支持。讨论:https://github.com/Microsoft/TypeScript/issues/4691