首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >问号作为图标出现在react本机应用程序中。

问号作为图标出现在react本机应用程序中。
EN

Stack Overflow用户
提问于 2020-01-10 09:10:48
回答 2查看 2.4K关注 0票数 0

我正在尝试将图标应用到我的react本机项目中,因此我安装了:

1.npm install react-native-vector-icons --save

2.react-native link react-native-vector-icons

在此部分之后,添加到android/app/sec/main/assets/fonts中的所有图标

代码语言:javascript
复制
ls -l /media/groot/Project/React\ Native/Practices/RNheader/android/app/src/main/assets/fonts
total 1976
-rwxrwxrwx 1 groot groot  70344 Jan  9 16:45 AntDesign.ttf
-rwxrwxrwx 1 groot groot  65584 Jan  9 16:45 Entypo.ttf
-rwxrwxrwx 1 groot groot  13456 Jan  9 16:45 EvilIcons.ttf
-rwxrwxrwx 1 groot groot  58272 Jan  9 16:45 Feather.ttf
-rwxrwxrwx 1 groot groot 125016 Jan  9 16:45 FontAwesome5_Brands.ttf
-rwxrwxrwx 1 groot groot  34092 Jan  9 16:45 FontAwesome5_Regular.ttf
-rwxrwxrwx 1 groot groot 186228 Jan  9 16:45 FontAwesome5_Solid.ttf
-rwxrwxrwx 1 groot groot 165548 Jan  9 16:45 FontAwesome.ttf
-rwxrwxrwx 1 groot groot 313528 Jan  9 16:45 Fontisto.ttf
-rwxrwxrwx 1 groot groot  56976 Jan  9 16:45 Foundation.ttf
-rwxrwxrwx 1 groot groot 112472 Jan  9 16:45 Ionicons.ttf
-rwxrwxrwx 1 groot groot 546548 Jan  9 16:45 MaterialCommunityIcons.ttf
-rwxrwxrwx 1 groot groot 128180 Jan  9 16:45 MaterialIcons.ttf
-rwxrwxrwx 1 groot groot  28364 Jan  9 16:45 Octicons.ttf
-rwxrwxrwx 1 groot groot  54056 Jan  9 16:45 SimpleLineIcons.ttf
-rwxrwxrwx 1 groot groot  25552 Jan  9 16:45 Zocial.ttf
  1. 我在js文件中添加了如下内容: 从“react本机-矢量-图标/Ionicons”导入图标;

这是我的档案:

代码语言:javascript
复制
import React from 'react';
import { View, Text, Button, StyleSheet } from 'react-native';
import Icon from "react-native-vector-icons/Ionicons";


export default HeaderView = () => {
    return (
        <View style={styles.headerStyle} >
            <View style={styles.columnStyle}>
                <Icon name="arrow-back" size={15}/>

            </View>
            <Text>Test</Text>
        </View>)
}

但是,当我在android模拟器上运行项目时,图标显示为?

我收到这样的警告:

这就是我的错误吗?

我想我添加了正确的图标名称:

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-01-10 10:04:29

您需要使用md-arrow-back而不是arrow-back

原因如图标网站上所述,

当使用没有Ionic框架的Ionicons时,图标将默认为Material图标样式。若要指定非默认图标样式,请在name属性中添加平台前缀.

这意味着如果您没有在离子框架中使用它,则必须在任何图标名称之前添加前缀,即md

您可以在使用页面 of 图标中查看更多内容。

票数 1
EN

Stack Overflow用户

发布于 2020-01-10 09:20:06

这意味着您提供的回箭头的名称对于该图标(将name="arrow-back"更改为name="md-arrow-back" )无效。如果您真的想使用箭头-backMaterialIcons导入而不是Ionicons

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59678532

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档