【问题标题】:React-native-vector-icons show obscure symbolsReact-native-vector-icons 显示晦涩的符号
【发布时间】:2019-11-19 11:02:27
【问题描述】:

我已经安装了react-native-vecotor。并且在使用它们时,它们会显示出晦涩的符号。如何使用这个库?平台:安卓

import React from 'react';
import {View, Text, StyleSheet} from 'react-native';
import Icon from 'react-native-vector-icons/Ionicons';

const SearchBar = () => {
    return (
        <View style={styles.background}>
            <Icon name="md-body" color='#000'  size={25} />
        </View>
    );
};
const styles = StyleSheet.create({
    background:{
        backgroundColor:'#F0EEEE',
        marginHorizontal: 15,
        height:45,
        borderRadius:5,
    }
});
export default SearchBar;

【问题讨论】:

  • 你有没有把自定义字体放到这个目录:android/app/src/main/assets?
  • @mohsen.h 不,怎么放?
  • 你必须将 iconmoon.ttf 添加到这个目录的手册中,我认为它确实有效。
  • @mohsen.h 在 android/app/src/main/assets/fonts 目录中有许多扩展名为 .ttf 的文件。像 AntDesign、FontAwesome
  • 目录下是否有ionicons.ttf?

标签: javascript reactjs react-native npm icons


【解决方案1】:

Ionicons 没有元素名称 body。你可以在这里查看react-native-vector-icons

<Icon name="ios-body" color='#000'  size={25} />

【讨论】:

    【解决方案2】:

    如果你使用的是 react-native 版本 0.60++ 那一定是链接问题!

    我在更新 react-native 后遇到了同样的问题,但通过这个解决了,请按照我的指示进行操作。

    1. 清理你的 gradlew(可选但推荐)
      要清理 gradle,请转到 android 文件夹并打开 cmd 并运行 gradlew clean

    2. 转到android/app/build.gradle在文件末尾添加这个=> apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

    3. 现在重新编译(react-native run-android)它现在必须工作!..

    【讨论】:

      【解决方案3】:

      我只是从我的设备重新安装项目应用程序。成功了!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-10-05
        • 2017-09-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多