作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有这些不同的数据模型。
我在其他数据模型中使用了枚举类型。
现在我可以比较 __typename
?
enum ActivtiyCardType {
Dance,
ReferralTransaction,
}
type ActivityCardData = {
__typename:ActivtiyCardType,
id:string,
from:{
__typename:string,
from:string,
id:string
}
to:{
__typename:string,
to:string,
id:string
}
date:Date,
message:string,
danceSuccessful:boolean,
amount?: number
}
type ActivityCardsProps = {
data: ActivityCardData[]
}
{data?.map((activity:ActivityCardData) => {
return (
<Paper
key={activity.id}
sx={{
m: 1,
p: 3,
}}
>
<Box>
**{activity.__typename === 'Dance' ? (**
如何比较
__typename
在这种情况下?
最佳答案
那么为什么不只是这个?
activity.__typename === ActivtiyCardType.Dance
关于node.js - 如何使用其他数据模型类型脚本处理枚举数据模型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70159576/
我是一名优秀的程序员,十分优秀!