【问题标题】:react-native-vector-icons don't work in Expo projectreact-native-vector-icons 在 Expo 项目中不起作用
【发布时间】:2018-12-25 12:29:19
【问题描述】:

我在我的 Expo 项目中安装了 react-native-vector-icons。 但它不起作用。

import Icon from 'react-native-vector-icons/SimpleLineIcons';

它显示了这个错误

这是 package.json

{
  "main": "node_modules/expo/AppEntry.js",
  "private": true,
  "dependencies": {
    "antd-mobile": "^2.1.8",
    "expo": "^27.0.1",
    "firebase": "^4.13.1",
    "moment": "^2.22.1",
    "native-base": "^2.4.3",
    "react": "16.3.1",
    "react-dom": "^16.3.2",
    "react-native": "https://github.com/expo/react-native/archive/sdk-27.0.0.tar.gz",
    "react-native-countdown": "0.0.3",
    "react-native-countdown-clock": "^2.0.2",
    "react-native-countdown-component": "^1.6.0",
    "react-native-countdown-hint": "^0.0.3",
    "react-native-render-html": "^3.9.3",
    "react-native-star-rating": "^1.0.9",
    "react-native-swiper-flatlist": "^1.0.6",
    "react-native-timeago": "^0.4.0",
    "react-native-vector-icons": "^4.6.0",
    "react-navigation": "^1.5.11",
    "simple-line-icons": "^2.4.1",
    "tcomb-form-native": "^0.6.11"
  }
}

我通过yarn install 安装了软件包并尝试了npm install 但都没有工作

【问题讨论】:

    标签: icons expo


    【解决方案1】:

    尝试看看这是否有效。

    import SimpleLineIcons from 'react-native-vector-icons/SimpleLineIcons';

    【讨论】:

      【解决方案2】:

      对于 iOS: https://medium.com/@vimniky/how-to-use-vector-icons-in-your-react-native-project-8212ac6a8f06 对于android,我刚刚解决了这个问题:

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

      这一行粘贴到 android/app/build.gradle(app) 中。然后重新运行android。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-05-20
        • 2017-09-16
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多