使用图标库 react-native-vector-icons 报错
学习 react-navigation 时使用到了react-native-vector-icons,
原文中使用expo,
// You can import Ionicons from @expo/vector-icons if you use Expo or
// react-native-vector-icons/Ionicons otherwise.
import { Ionicons } from '@expo/vector-icons';
我并没有expo 所以
import {Ionicons} from 'react-native-vector-icons/Ionicons';
npm install react-native-vector-icons,然后在 android\app\build.gradle 里面加上 apply from: "../../node_modules/react-native-vector-icons/fonts.gradle",就报了如下所示的错误:
看了TabBarIcon 并没有错误,换了FontAWesome,不报错误,
错误原因 import {Ionicons} from 'react-native-vector-icons/Ionicons'; 没有{}
应为 import Ionicons from 'react-native-vector-icons/Ionicons';