react-native-vector-icons在Expo项目中不起作用

时间:2018-07-17 17:51:30

标签: icons expo

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

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

它显示此错误 enter image description here

这是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 但两者都不起作用

2 个答案:

答案 0 :(得分:0)

尝试查看是否可行。

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

答案 1 :(得分:0)

对于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。