【问题标题】:Style the last element of dropdown menu React Native为下拉菜单的最后一个元素设置样式 React Native
【发布时间】:2021-01-27 17:47:54
【问题描述】:

我想在 React native 中为下拉菜单的最后一个元素设置样式。

我正在使用一个名为 React 本机下拉选择器的库。

它有一个名为 itemStyle 的道具,您可以在其中传递项目的样式。

item: {
    height: 35,
    justifyContent: 'flex-start',
    paddingLeft: 5,
    borderBottomWidth: 1,
    borderBottomColor: '#000',
  },

The elements style in dropdown

所以我想将最后一个元素的 borderBottomWidth 从 1px 更改为 0。

不知道有没有可能。

对不起,如果我的英语不好。

【问题讨论】:

    标签: css reactjs react-native styled-components


    【解决方案1】:

    此库中有一个 renderSeperator 属性,如 pull request 中所述,但自述文件中没有记录。

    所以试试这个

    <DropDownPicker
    ....
    renderSeperator={() => <View style={{ backgroundColor: '#000', height: 1 }}>}
    />
    

    并从当前 itemStyle 中删除这部分

    borderBottomWidth: 1,
    borderBottomColor: '#000',
    

    【讨论】:

    • 我添加但没有成功。 itemStyle={styles.item} item: { height: 35, justifyContent: 'flex-start', paddingLeft: 5, }, renderSeperator={() => ( )}
    • 你在使用this库对吗?
    猜你喜欢
    • 2020-12-06
    • 1970-01-01
    • 2018-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-21
    • 1970-01-01
    相关资源
    最近更新 更多