【问题标题】:Search Bar Icon not shown | React native搜索栏图标未显示 |反应原生
【发布时间】:2019-09-27 15:14:46
【问题描述】:

搜索图标被其他图标取代。如何在 SearchBar 中放置图标(React-native-elements || React-native) 图标的屏幕截图。

【问题讨论】:

    标签: react-native icons uisearchbar


    【解决方案1】:

    找到解决方案。 对于一些 react-native 版本,我们需要手动链接模块。在这种情况下,我必须链接 react-native-vector-icons。

    npm install react-native-vector-icons--save
    
    react-native link react-native-vector-icons
    

    来自项目目录。

    【讨论】:

    • 我有同样的问题: - react-native 0.62.2 - react-native-elements ^1.2.7 - react-native-vector-icons: ^6.6.0 我什至无法解决它运行link 命令。
    • @ThachHuynh 我设法按照 Github 的说明解决了这个问题:github.com/oblador/react-native-vector-icons#installation 在您完成了以下操作后。关闭您的机器并在 10 秒后重新启动它?我跳过了要求我将 react-native-elements 文件夹中的字体复制到我的 RN 项目中的 android assets/fonts 文件夹中的步骤。
    【解决方案2】:

    我做了这些:

    npm install react-native-vector-icons--save
    
    react-native link react-native-vector-icons
    

    然后从模拟器中关闭应用程序卸载它只是为了安全起见:

    npm start
    
    react-native run-android
    

    【讨论】:

      【解决方案3】:

      我刚刚设法为我的项目解决的另一个解决方案。 只需按照说明进行操作: https://github.com/oblador/react-native-vector-icons#installation

      我遇到了提示我使用重复字体的错误。您可能想跳过它提到从 react-native-elements 复制 Fonts 文件夹并将其放入驻留在您的 react native 项目中的 src/assets/fonts 文件夹的部分。

      关闭您的笔记本电脑,然后等待大约 10 秒再重新启动。我希望它对遇到与我(或我们)相同问题的人有所帮助。

      只想分享我项目中使用的版本-

      依赖”:{

      ..
      **"react": "17.0.2",
      "react-native": "0.67.3",
      "react-native-elements": "^3.4.2",
      "react-native-safe-area-context": "^4.0.1",
      "react-native-screens": "^3.12.0",**
      ...
      **"react-native-vector-icons": "^9.1.0"**
      

      },

      【讨论】:

        【解决方案4】:

        我想我曾经遇到过这个问题并通过在 android>app>build.gradle 末尾添加这一行来解决它

        apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
        

        然后执行 ./gradlew clean 并再次运行应用程序

        【讨论】:

          【解决方案5】:

          这里是文档中的代码:

          import { Icon } from 'react-native-elements'
          
          <Icon
            name='rowing' />
          
          <Icon
            name='g-translate'
            color='#00aced' />
          
          <Icon
            name='sc-telegram'
            type='evilicon'
            color='#517fa4'
          />
          
          <Icon
            reverse
            name='ios-american-football'
            type='ionicon'
            color='#517fa4'
          />
          
          <Icon
            raised
            name='heartbeat'
            type='font-awesome'
            color='#f50'
            onPress={() => console.log('hello')} />
          
          

          【讨论】:

          • 图标应该显示在搜索栏中。所以这没有意义。有人可以帮助在搜索栏中导入或包含图标吗?
          • 图标无法从 react-native-elements 导入图标有一个特定的包名:react-native-vector-icons
          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2022-01-24
          • 2018-12-09
          • 1970-01-01
          • 2014-11-29
          • 1970-01-01
          相关资源
          最近更新 更多