簡體   English   中英

react-native 中沒有出現圖標

[英]Icons are not appearing in react-native

我正在使用react-native-vector-icons/FontAwesome來顯示圖標和react-navigation來顯示選項卡。 我試圖在按鈕導航中顯示主頁圖標,但圖標沒有出現。

Icon和createBottomTabNavigator的PFB相關代碼

import React from 'react';
import { createBottomTabNavigator } from 'react-navigation';
// import { Icon } from 'react-native-elements';
import Icon from 'react-native-vector-icons/FontAwesome';

import Account from '../../Form/components/Account';
import Home from '../../Layout/components/Home';

export const Tabs = createBottomTabNavigator({
  Account: { 
    screen: Account,
    navigationOptions: {
      tabBarLabel: 'Account',
      tabBarIcon: ({ tintColor }) => <Icon name="rocket" size={35} color="#fdc94c" />
    }
  },
  Home: { 
    screen: Home,
    navigationOptions: {
      tabBarLabel: 'Home',
      tabBarIcon: ({ tintColor }) => <Icon name="rocket" size={35} color="#fdc94c" />
    },
 }
}, {
  order: ['Home', 'Account'],
  tabBarOptions: {
      showLabel: true,
      showIcon: true,
      activeBackgroundColor: '#42a5f5',
      style: {
        backgroundColor: '#42a5f5',
        paddingVertical: 10,
        height: 60
      },
      indicatorStyle: {
        backgroundColor: '#42a5f5',
      }
    }
})

PFB 截圖也是如此。

我需要做什么才能顯示主頁圖標? 在此處輸入圖像描述

通過使用react-native link react-native-vector-icons確保字體已鏈接到您的 iOS 工作區,然后重建應用程序

按照文檔並確保按照他們提到的那樣設置所有內容https://github.com/oblador/react-native-vector-icons#ios

運行命令 npm i -g rnpm。 並在項目文件夾上運行 rnpm 鏈接。 然后運行項目。

在您的項目文件夾中運行以下命令。

$react-native 鏈接

您是否已將其粘貼到應用級別 gradle android\app\build.gradle

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM