對應不同平台的 UI 佈局與樣式調整,也可以做到 JS 行為的不同 facebook F8 App 開發紀錄 - Designing an App for Multiple Platforms: http://makeitopen.com/
- MyComponent.ios.js
- MyComponent.android.js
import MyComponent from './MyComponent';
- iOS
- android
import { Platform, StyleSheet } from 'react-native';
const styles = StyleSheet.create({
container: {
height: Platform.OS === 'ios' ? 200 : 100
}
});
import { Platform, StyleSheet } from 'react-native';
const styles = StyleSheet.create({
container: {
flex: 1,
...Platform.select({
ios: {
backgroundColor: 'red'
},
android: {
backgroundColor: 'blue'
}
})
}
});