首页 > 解决方案 > 当我使用 Nativebase getImageSource React native 时显示 RNVectorIcons 模块不可用

问题描述

当我使用 Native Base 矢量图标时,它显示“RNVectorIcons 模块不可用”

我正在安装 Native Base 但没有单独安装 RN-Vector-Icons

你能找到这个错误吗?它对我或其他人真的有帮助吗

这里是完整的错误图像

import { Navigation } from "react-native-navigation";
import Icon from 'react-native-vector-icons/AntDesign'; // for nativeBase getImageSource

const goAuth = () => {
    Promise.all([
        Icon.getImageSource('adduser', 15),
        Icon.getImageSource('login', 15)
    ]).then(source => {
        Navigation.setRoot({
            root: {
                id: 'authSccreen',
                bottomTabs: {
                    children: [{
                        component: {
                            name: 'signIn',
                            options: {
                                text: 'signIn',
                                icon: source[0]
                            }
                        }
                    },
                    {
                        component: {
                            name: 'signUp',
                            options: {
                                text: 'signUp',
                                icon: source[1]
                            }
                        }
                    }],
                }
            }
        })
    })
}

export default goAuth

并检查此图像,它显示 GetImageSource 已安装在图标导入中

在此处输入图像描述

标签: react-nativenative-basereact-native-vector-icons

解决方案


npm install react-native-vector-icons您拥有该矢量图标库的链接之后。如果您尝试使用android ,我认为您忘记链接该库只需触发此命令

react-native link react-native-vector-icons

对于ios

将以下内容添加到您的 Podfile 并运行 pod update:

pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'

如上所述编辑 Info.plist。

如果您使用的是 use_frameworks!在您的 Podfile 中,您需要在引导应用程序时通过执行 Icon.loadFont() 来动态加载图标字体。


推荐阅读