【问题标题】:react-native-vector-icons or @expo/vector-icons not rendering on android devicereact-native-vector-icons 或 @expo/vector-icons 未在 android 设备上呈现
【发布时间】:2021-07-22 17:59:41
【问题描述】:

在我尚未弹出的世博会项目中,图标没有在 android 上呈现。我使用 npm 安装了包。我在 web 浏览器上呈现了 cons,但在 android 上没有呈现。

npm i react-native-vector-icons

import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';

<MaterialCommunityIcons name="plus-box" color={color} size={26} />

【问题讨论】:

  • 您可以尝试从 MaterialCommunityIcons 中删除大括号并测试 import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';

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


【解决方案1】:

使用 react-native-vector-icons 时没有大括号

 import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'

使用@expo/vector-icons 时

import { MaterialCommunityIcons } from '@expo/vector-icons';

【讨论】:

  • 我试过带和不带花括号。但没有运气
  • 这对两者都适用,以防您可以检查提供的颜色
  • 颜色不会改变任何东西
  • 我的意思是这样做在 Android 中可以正常工作,您可以检查其他属性,例如颜色或添加的视图可能与图标重叠
猜你喜欢
  • 2021-03-09
  • 2017-09-16
  • 1970-01-01
  • 1970-01-01
  • 2018-12-25
  • 1970-01-01
  • 2022-10-05
  • 2018-01-16
  • 1970-01-01
相关资源
最近更新 更多