用于识别部署在移动应用程序还是 Web 应用程序上的环境变量?
Environment variable to recognise if deployed on Mobile App or Web App?
您好,我在 Angular 中使用 Ionic 5。我有一个移动应用程序,我目前正在为其开发 Web 应用程序,它使用与移动应用程序相同的代码库。
我正在寻找一种方法来配置一些环境变量以识别该应用程序是部署在移动应用程序还是 Web 应用程序上。谢谢:)
import {Platform } from '@ionic/angular';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage = HomePage;
constructor(platform: Platform) {
platform.ready().then(() => {
if (this.platform.is('android')) {
console.log("running on Android device!");
}
if (this.platform.is('ios')) {
console.log("running on iOS device!");
}
if (this.platform.is('mobileweb')) {
console.log("running in a browser on mobile!");
}
});
}
}
您好,我在 Angular 中使用 Ionic 5。我有一个移动应用程序,我目前正在为其开发 Web 应用程序,它使用与移动应用程序相同的代码库。
我正在寻找一种方法来配置一些环境变量以识别该应用程序是部署在移动应用程序还是 Web 应用程序上。谢谢:)
import {Platform } from '@ionic/angular';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage = HomePage;
constructor(platform: Platform) {
platform.ready().then(() => {
if (this.platform.is('android')) {
console.log("running on Android device!");
}
if (this.platform.is('ios')) {
console.log("running on iOS device!");
}
if (this.platform.is('mobileweb')) {
console.log("running in a browser on mobile!");
}
});
}
}