[英]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!");
}
});
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.