首页 > 解决方案 > 字体系列materialicon不是系统字体

问题描述

我的代码正在使用 react-native-paper 工具包。但不是任何图标直接。并且不在我的代码中加载任何自定义字体。捆绑包下载后,发生红屏崩溃。我在我的 android 8.1 上运行它。节点 10.4 和 npm 6.5。

请建议。

我的 package.json:

  "dependencies": {
    "expo": "^29.0.1",
    "react": "16.5.0",
    "react-native": "~0.55.4",
    "prop-types": "^15.0.0",
    "eslint": "^3.17.0",
    "react-native-navigation": "^2.5.2",
    "react-native-paper": "^2.5.0",
    "react-native-permissions": "^1.1.1",
    "react-native-status-bar-height": "*",
    "react-native-vector-icons": "^6.1.0",
    "react-navigation": "^3.0.9"
  },
  "devDependencies": {
    "babel-preset-expo": "^4.0.0"
  },

应用程序.json:

"expo": {
    "name": "AwesomeProject",
    "slug": "AwesomeProject",
    "privacy": "public",
    "sdkVersion": "29.0.0",
    "platforms": [
      "ios",
      "android"
    ],
    ...

标签: androidreact-nativefontsexpo

解决方案


如果您按照react-native-paper 的说明操作,它会告诉您它需要安装react-native-vector-icons才能工作:

yarn add react-native-vector-icons OR npm install react-native-vector-icons
react-native link react-native-vector-icons

请注意,在 react-native 中的链接经常在 android 上被破坏,所以为了您的方便,这里是手动 android 链接的指南。react-native-vector-icons


推荐阅读