【问题标题】:import Icon from 'react-native-vector-icons/Ionicons'从“react-native-vector-icons/Ionicons”导入图标
【发布时间】:2017-11-23 11:15:47
【问题描述】:

我可以在同一屏幕上导入 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';

【问题讨论】:

  • 你尝试使用'import as'吗?从 'react-native-vector-icons/font-awesome' 导入 {Icon as Icon1};从 'react-native-vector-icons/Ionicons' 导入 {Icon as Icon2};

标签: reactjs icons react-native-android vector-icons


【解决方案1】:

是的,你可以。因为 FontAwesome 和 Ionicons 是作为默认值导出的,所以您可以使用任何名称导入它们,就像这样

import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome';
import IonIcon from 'react-native-vector-icons/Ionicons';

并在您的 render() 方法中使用 like

<FontAwesomeIcon name="github" size={16} color="red">
<IonIcon name="github" size={16} color="blue">

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多