首页 > 移动平台 > 详细

ReactNative: Android与iOS平台兼容处理

时间:2019-11-30 15:13:52      阅读:78      评论:0      收藏:0      [点我收藏+]
方法一:

创建不同的文件扩展名:
*.android.js

*.io.js

方法二:

import { Platform } from ‘react-native‘;

if (Platform.OS === ‘android‘) {
     // Do something specific for Android
   } else if (Platform.OS === ‘ios‘) {
     // Handle iOS
} 

marginTop: Platform.OS === ‘ios‘ 10 : 0, 
paddingBottom: Platform.OS === ‘android‘   8 : 0

方法三:

const myStyle = Platform.select({ios:{},android:{})

const myFn = Platform.select({ios:()=>{},android:()=>{})
myFn();

方法四:

if (UIManager.setLayoutAnimationEnabledExperimental) {
       UIManager.setLayoutAnimationEnabledExperimental(true);
} 

ReactNative: Android与iOS平台兼容处理

原文:https://blog.51cto.com/14565733/2454644

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!