WHERE NOT EXISTS
我有这段代码用于在用户界面中显示多个项目。 data.listArts.items包含大约100个元素。
此映射执行结束后,我想调用一个函数,以便调用的函数可以与reactJS中呈现的HTML一起使用。
答案 0 :(得分:1)
Map没有回调(到达数组末尾时),但是您始终可以检查是否到达最后一个元素并调用函数。
TaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
Family: !Ref Family
Cpu: !Ref Cpu
Memory: !Ref Memory
NetworkMode: awsvpc
ExecutionRoleArn: !Ref ExecutionRoleArn
TaskRoleArn: !Ref TaskRoleArn
RequiresCompatibilities:
- FARGATE
ContainerDefinitions:
- Name: !Ref ContainerName
Essential: true
Image: !Ref Image
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref LogGroup
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: !Ref LogPrefix
答案 1 :(得分:0)
检查带有索引的数组的长度
data.listArts.items.map((art, index) => {
if(data.listArts.items.length -1 == index){
//do what you want to do here may be a flag set here
}
return (
<a className="thumbnail" key={index}>
<img src={art.ArtURL}/>
</a>
);}
)}