【问题标题】:React-Native-Element icon shows up as cross in search barReact-Native-Element 图标在搜索栏中显示为十字
【发布时间】:2017-07-16 03:41:42
【问题描述】:

如何更改 react-native-element 中搜索栏的图标。

<Icon type='font-awesome' name="share-alt" size={33} color="red" />

上面的代码确实可以正确渲染图标。

但相同的图标在以下代码中显示为叉号

<SearchBar
    lightTheme
    icon = {"share-alt", "red"}
    inputStyle={{margin: 0, padding:3, flex:1}}
    containerStyle={{flex:1, height:undefined}}
    onChangeText={() => {}}
    placeholder='ABC' />

【问题讨论】:

  • 你能附上屏幕截图吗?
  • 添加了屏幕截图

标签: react-native icons font-awesome searchbar


【解决方案1】:

您只能更改本机图标。它的列表在这里https://material.io/icons/

icon 属性不接受 type 。这里指定react-native-elements/API/searchbar/

 object {name (string), color (string), style (object)}

【讨论】:

    【解决方案2】:

    根据您的屏幕截图,react-native-vector-icons 未正确安装。
    1.正确安装react-native-vector-icons
    2.然后你可以看到搜索图标。届时,您可以更改搜索栏的图标。你可以使用Material icon names

    【讨论】:

      【解决方案3】:

      确保您在安装后已链接矢量图标

      npx react-native link react-native-vector-icons
      

      然后确保停止打包程序并重新编译应用程序。现在图标应该出现了。安装链接后图标一般不会加载,需要重新编译。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-09-25
        • 1970-01-01
        • 2020-06-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多