从“react-native-vector-icons/Ionicons”导入图标

Kam*_*ani 3 icons reactjs react-native vector-icons

我可以在同一屏幕上导入react-native-vector-icons/font-awesome 和react-native-vector-icons/Ionicons 吗?基本上我想在同一屏幕上为不同的图标使用 font-awesome 和 Ionicons 图标?

Example-
import ActionButton from 'react-native-action-button';
import Icon from 'react-native-vector-icons/font-awesome';
import Icon from 'react-native-vector-icons/Ionicons';
Run Code Online (Sandbox Code Playgroud)

mag*_*icz 6

是的你可以。由于 FontAwesome 和 Ionicons 是默认导出的,因此您可以使用任何名称导入它们,如下所示

import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome';
import IonIcon from 'react-native-vector-icons/Ionicons';
Run Code Online (Sandbox Code Playgroud)

并在你的render()方法中使用像

<FontAwesomeIcon name="github" size={16} color="red">
<IonIcon name="github" size={16} color="blue">
Run Code Online (Sandbox Code Playgroud)