23

反应原生自动链接不适用于反应原生矢量图标。我用这个 https://github.com/oblador/react-native-vector-icons/issues/1035将它修复到 android

但是在IOS上我仍然面临问题。如果有人解决了这个问题,请告诉我...谢谢!

这是屏幕截图我面临的问题。

在此处输入图像描述

4

5 回答 5

52

这在升级项目和全新的 RN 0.60.0 上对我有用

对于 IOS 将其添加到 ios/projectname/Info.plist

<key>UIAppFonts</key>
    <array>
        <string>AntDesign.ttf</string>
        <string>Entypo.ttf</string>
        <string>EvilIcons.ttf</string>
        <string>Feather.ttf</string>
        <string>FontAwesome.ttf</string>
        <string>FontAwesome5_Brands.ttf</string>
        <string>FontAwesome5_Regular.ttf</string>
        <string>FontAwesome5_Solid.ttf</string>
        <string>Foundation.ttf</string>
        <string>Ionicons.ttf</string>
        <string>MaterialCommunityIcons.ttf</string>
        <string>MaterialIcons.ttf</string>
        <string>Octicons.ttf</string>
        <string>SimpleLineIcons.ttf</string>
        <string>Zocial.ttf</string>
    </array>

对于 Android,将此行添加到 android/app/build.gradle

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

这解决了我的问题,并对在这两个平台上工作的原生矢量图标做出反应。

于 2019-07-11T09:38:11.737 回答
2

如果你react-native link在 iOS 上做了cd ios,然后pod install.

一些包仍然需要由维护者更新才能与 react native 一起工作。

Aniway,如果您不想链接,请进入您的 podfile 并添加:

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

之后做我之前说的同样的步骤

于 2019-07-11T08:57:10.440 回答
1

npx react-native link

在根文件夹项目中解决此问题。

希望能帮助到你。

于 2019-11-08T09:11:18.887 回答
-1

字体、图像和其他外部资产仍应使用react-native link命令链接,这是该命令仍然存在的唯一原因。

但是,链接资产的配置发生了变化,过去是通过在 package.json 中放置一个带有要链接的路径的 rnpm 条目。在这里检查。

现在链接 fontawesome 的正确方法是使用react-native.config.js文件。

1 - 创建一个react-native.config.js文件

 module.exports = {
      project: {
        ios: {},
        android: {},
      },
      assets: [
        './node_modules/react-native-vector-icons/PATH_TO_FONT_A',
        './node_modules/react-native-vector-icons/PATH_TO_FONT_B',
      ],
    };

2 - 运行命令

react-native link

这一次,现在,链接命令将产生一条日志消息,例如

info Linking assets to ios project
warn Group 'Resources' does not exist in your Xcode project. We have created it automatically for you.
info Linking assets to android project
success Assets have been successfully linked to your project
于 2019-09-19T18:16:47.750 回答
-1

从 'react-native-vector-icons/Feather' 导入图标;

图标.loadFont();

试试这个

于 2020-05-18T15:12:47.557 回答