首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何遍历html中的Set。

如何遍历html中的Set。
EN

Stack Overflow用户
提问于 2019-09-19 01:42:49
回答 1查看 140关注 0票数 0

我尝试在包含其他集合的集合上使用*ngFor。

代码语言:javascript
运行
复制
<div class="card-deck" *ngFor="let cardDeck of recentlyAdded; let i=index">
                    <div class="card" *ngFor="let documentary of cardDeck">
                        <img [src]="getSantizeUrl(documentary.poster)" class="card-img-top" alt="...">
                        <div class="card-body">
                        <h5 class="card-title">{{ documentary.title }}</h5>
                        <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                        <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                        </div>
                    </div>
                </div>

..。

pastebin其他代码https://pastebin.com/AP1Vwa7P

没有控制台错误,只有html源代码中有这样的错误:

代码语言:javascript
运行
复制
<!--bindings={
  "ng-reflect-ng-for-of": "[object Set]"
}-->
EN

回答 1

Stack Overflow用户

发布于 2019-09-19 01:52:47

要迭代Set,首先必须将其转换为Array,然后遍历它。

代码语言:javascript
运行
复制
let arrayOfSet= Array.from(pass your set)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57998201

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档