我正在尝试使用
kayaking
图标,它是 MaterialCommunityIcons
的一部分,但该图标似乎不存在或其他东西。
但是,我可以让其他图标发挥作用。看看这个网站 react-native-vector-icons 目录,我发现
kayaking
实际上是一个图标。这个链接也这么说:Github 图标目录。
那么为什么我无法让图标工作?
这就是我尝试过的方法:
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
// DOES NOT WORK
<Icon name="kayaking" />
// BUT THE BELOW DOES WORK
<Icon name="access-point" />
我也尝试过这个:
import { MaterialCommunityIcons } from "@expo/vector-icons";
// DOES NOT WORK
<MaterialCommunityIcons name="kayaking"/>
// BUT THE BELOW DOES WORK
<MaterialCommunityIcons name="access-point"/>
有人可以告诉我发生了什么事吗?就这么简单,但是好像
kayaking
图标已经不存在了……
在您发布的第二个代码块中,导入语句不正确,应更新为:
import MaterialCommunityIcons from '@expo/vector-icons/MaterialCommunityIcons';
更新此内容后,您的第二个代码块应该开始正常工作。
对于 Expo React Native 项目,找到确切的图标名称并从该站点导入:https://icons.expo.fyi/Index