我需要一个特定的样式来仅适用于 android 并且需要在 iOS 上无效。
我的代码片段有点像这样:
<CardItem
style={{
borderWidth: 0,
borderLeftWidth: 0,
borderRightWidth: 0,
borderTopLeftRadius: 10,
borderTopRightRadius: 10,
borderBottomLeftRadius: 0,
borderBottomRightRadius: 0,
backgroundColor: "#fff",
overflow: Platform.OS == "ios" ? "hidden":"auto"
}}
cardBody
>
我需要仅在 iOS 上 overflow hidden ,而在 android 上不需要任何影响。我使用过溢出:Platform.OS == "ios"吗? "hidden":"auto" ,但看起来不适合这种情况。
在这方面需要帮助。
最佳答案
Overflow 属性在 react-native 上没有 auto
值。那是枚举,有这些:
enum('visible', 'hidden', 'scroll')
为 android 设置可见而不是自动。 (这是默认值)
overflow: Platform.OS == "ios" ? "hidden": "visible"
应该可以。
关于css - react-native: 仅适用于 android/ios 的平台特定样式代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55743424/