【发布时间】:2022-06-14 06:03:19
【问题描述】:
我正在尝试找出 expo/vector-icons 图标名称的类型定义,因为我打算将它用于组件道具。
我正在导入expo/vector-icons,并像这样定义界面道具,我尝试将图标名称输入为字符串。
import Icon from "@expo/vector-icons/FontAwesome"
interface Props {
icon: string
value: string
placeholder: string
onChangeText: (text: string) => void
secureTextEntry?: boolean
style: StyleProp<ViewStyle>
}
这就是我使用道具的方式。
<Icon name={icon} size={20} style={styles.icon} />
【问题讨论】:
-
我想您可能会发现this question 很有帮助。 name 属性不是字符串,而是 glyphMap。