gpt4 book ai didi

node.js - 如何使用其他数据模型类型脚本处理枚举数据模型?

转载 作者:行者123 更新时间:2023-12-04 17:07:52 25 4
gpt4 key购买 nike

我有这些不同的数据模型。
我在其他数据模型中使用了枚举类型。
现在我可以比较 __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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com