怎么判断是Android平台还是iOS平台呢?
reactnative吧
全部回复
仅看楼主
level 2
夏逸居士 楼主
唉,来晚了,没有名字被占了,就是因为国内的中文资料太特么少了,学得费劲。
如题,怎么判断是Android平台还是iOS平台呢?
我想做一些平台差异的适配,需要判断平台,不知有没有哪位先驱知道?
[勉强]
2015年10月20日 09点10分 1
level 1
不需要判断平台,因为react native运行的时候会根据以下规则进行差异化加载:
1、可以使用文件夹层名对两个平台的组件进行区分,例如:
公用的:/common/components/
android的:/android/components/
ios的:/ios/components/
2、可以使用文件名进行区分,例如:
BigButtonIOS.js
BigButtonAndroid.js
3、类似于2,如:
BigButton.ios.js
BigButton.android.js
推荐使用3的方式,把两文件放在同一目录下,即可根据访问平台自动加载对应的js文件。
官方文档说明:http://facebook.github.io/react-native/docs/platform-specific-code.html#content
2015年12月31日 06点12分 2
谢谢,学到了[惊讶]
2016年01月03日 05点01分
level 2
Platform 组件判断 Platform.OS 的值
2016年01月06日 08点01分 4
level 1
建议看英文的,github上的awesome-react-native非常好,里面有很多资源,从入门到移动,网络,桌面开发的例子都很好。
2016年02月12日 03点02分 5
多谢分享
2016年03月08日 14点03分
level 1
中文资料少?那是你没找对地方 http://reactnative.cn/
2016年03月18日 06点03分 6
level 1
2016年03月18日 07点03分 7
level 6
2016年03月26日 10点03分 9
level 2
写在一个js文件这样
var React = require('react-native');
var {Platform} = React;
var iosPlatform = Platform === 'IOS'
分开js写应该是
index.android.js
index.ios.js这样吧
2016年03月26日 12点03分 10
level 7
platform.os可以获取平台
2016年05月08日 16点05分 11
1