react-native:仅适用于android / ios的平台特定样式代码

问题描述 投票:0回答:1

我需要一个特定的样式才能仅适用于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上隐藏,在Android上不需要任何效果。我用过overflow:Platform.OS ==“ios”? “隐藏”:“自动”,但不适合该场景。

需要帮助。

css react-native
1个回答
0
投票

溢出属性在react-native上没有auto值。这是枚举,并有这些:

枚举('可见','隐藏','滚动')

为android设置可见而不是自动。 (这是默认值)

overflow: Platform.OS == "ios" ? "hidden": "visible"

应该管用。

© www.soinside.com 2019 - 2024. All rights reserved.