NG-ZORRO / ng-zorro-antd

Angular UI Component Library based on Ant Design
https://ng.ant.design
MIT License
8.87k stars 3.94k forks source link

使用icon时,如果属性来源于类上的getter,会导致浏览器卡死 #6481

Closed werts closed 3 years ago

werts commented 3 years ago

Reproduction link

https://stackblitz.com/edit/ng-zoro-antd-icon-issue?file=src/app/app.module.ts

Steps to reproduce

取消AppComponent下的注释,使用注释的getter的items代替成员属性items即可重现

What is expected?

正常工作

What is actually happening?

浏览器卡死

Environment Info
ng-zorro-antd 11.2.0
Browser chrome 版本 89.0.4389.72(正式版本) (64 位)
zorro-bot[bot] commented 3 years ago

Translation of this issue:

When using ICON, if the property comes from the getter on the class, it will cause the browser card to die.

reproduction link

[https://stackblitz.com/Edit/ng-zoro-antd-icon-issue?file=src/app/app.module.ts](https://stackblitz.com/edit/ng- /oro-antd- Icon-Issue? file = src / app / app.module.ts)

steps to reproduce

Cancel the comment under AppComponent, use the ITEMS of the comment to replace the member attribute Items

What is expected?

normal work

What is actually happens?

Browser card

ENVIRONMENT INFO
Ng-Zorro-ANTD 11.2.0
Browser Chrome version 89.0.4389.72 (official version) (64-bit)
vthinkxie commented 3 years ago

https://ng.ant.design/docs/faq/zh#%E6%88%91%E7%9A%84%E9%A1%B5%E9%9D%A2%E5%8D%A1%E6%AD%BB%E4%BA%86%EF%BC%8C%E5%87%BD%E6%95%B0%E4%B8%8D%E5%81%9C%E7%9A%84%E5%9C%A8%E6%89%A7%E8%A1%8C 使用 getter,又没有trackBy,angular 每次拿到的都是新对象,相当于你写了一个死循环,页面肯定会卡死

werts commented 3 years ago

如果不使用icon,则不会导致卡死 @vthinkxie

vthinkxie commented 3 years ago

icon 内部会根据传入对象内容进行重新渲染

werts commented 2 years ago

@vthinkxie 还是没有特别理解,能不能帮忙说说到底是怎么个机制呢?感谢