本文介绍了如何在离子中找到设备操作系统和版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经完成了一些教程,最后在离子框架中发现了一些关于它的东西......

I have worked on few tutorials and at last found something regarding this in ionic framework.....

他们给出了一些使用离子原生的代码我做了嵌入下面的代码相同:

They gave some codes that use ionic native and i did the same by embedding the below code:

//Display OS name and version (Start)
import { Device } from 'ionic-native';


console.log('Device OS is: ' + Device.device.platform);
console.log('Device OS Version is: ' + Device.device.version);

//Display OS name and version (End) 

使用离子时我在控制台中得到了这个:

While using ionic serve i got this in the console:

'Device OS is: undefined'
'Device OS version is: undefined'

然后我猜测它不会在浏览器中工作,我尝试在手机中构建和运行但仍然是同样的日志来了...

Then i guessed it wont work in browser and i tried building and run in my phone but still the same log comes...

PS:我刚刚开始使用离子

PS: I have just started with ionic

提前谢谢你:)

推荐答案

请看这个链接

angular.module('PlatformApp', ['ionic'])
.controller('PlatformCtrl', function($scope) {

  ionic.Platform.ready(function(){
    // will execute when device is ready, or immediately if the device is already ready.
  });

  var deviceInformation = ionic.Platform.device();

  var isWebView = ionic.Platform.isWebView();
  var isIPad = ionic.Platform.isIPad();
  var isIOS = ionic.Platform.isIOS();
  var isAndroid = ionic.Platform.isAndroid();
  var isWindowsPhone = ionic.Platform.isWindowsPhone();

  var currentPlatform = ionic.Platform.platform();
  var currentPlatformVersion = ionic.Platform.version();

  ionic.Platform.exitApp(); // stops the app
});

这篇关于如何在离子中找到设备操作系统和版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 22:33