innerhalb JS-Datei können Sie mit folgenden (besser, wenn u schnellen müssen entscheiden, was zu verwenden pro Plattform Code)
/*at top file*/
var platform = require("platform");
var nativePlatformLocalhost;
/*in some function or globally*/
if(platform.device.os === platform.platformNames.ios){
/*localhost for ios*/
nativePlatformLocalhost= "localhost";
}
else if(platform.device.os === platform.platformNames.android){
/*localhost for android*/
nativePlatformLocalhost= "10.0.2.2";
}
oder wenn u-Notwendigkeit komplexer android/ios-Code basiert auf der Plattform und Sie können zwei Dateien ein für android und eine für ios mit Namenskonvention und erfordern schreiben, wie folgende Zeile
require("file.js");
Sie Datei erhalten, basierend auf laufende Plattform Laufzeit, wenn u
file.android.js
file.ios.js
http://docs.nativescript.org/ui/supporting-multiple-screens.html#platform-qualifiers