【问题标题】:Is there outline property in react-native?react-native 中是否有大纲属性?
【发布时间】:2019-05-01 02:35:38
【问题描述】:

Outline 属性在 CSS 中,但我尝试在 react-native 中使用 outline 属性。 我在使用带有 react-native 的大纲属性时遇到了以下消息。 错误:大纲属性不是有效的样式属性 任何人都知道 react-native 中 css 的属性而不是大纲属性,而无需安装另一个包。 感谢您的合作。

【问题讨论】:

标签: css react-native


【解决方案1】:

在 React Native 中,我们不能通过使用 outline: "red 2px solid" 来提供它,而是需要将其分解为单独的样式。想象一下,我们通过一个 javascript 对象来设置它的样式。

const styles = StyleSheet.create({
  button: {
    paddingHorizontal: 10,
    paddingVertical: 5,
    backgroundColor: "#e7622e",
    borderColor: "#fcfdfb",
    borderWidth: 2,
    outlineColor: "#523009",
    outlineStyle: "solid",
    outlineWidth: 4,
  },
  title: {
    color: "white",
  },
});

outlineColor: "#523009", outlineStyle: "solid", outlineWidth: 4 是它所理解的属性名称。

【讨论】:

  • 同时使用outlineColoroutlineStyleoutlineWidth,谢谢!感谢上帝。我开始担心 outline 在 React Native 中根本不存在,但它确实存在!
  • 如何用 css 模块做到这一点?
【解决方案2】:
style={{
        height: 40,
        width: "95%",
        borderRadius: 20,
        backgroundColor: this.state.boxColor,
        marginHorizontal: 10,
        fontFamily: ConstantFontFamily.defaultFont,
        fontWeight: "bold",
        paddingLeft: 35,
        minWidth:
            Dimensions.get("window").width >= 1100 ? 630 : 393,
        outline: "none"
    }}

【讨论】:

  • 请您解释一下您的答案好吗?
猜你喜欢
  • 2017-03-15
  • 1970-01-01
  • 2021-07-01
  • 2020-01-03
  • 2014-05-03
  • 1970-01-01
  • 2020-03-18
  • 1970-01-01
  • 2022-10-18
相关资源
最近更新 更多