gpt4 book ai didi

javascript - AngularJS 中的 ng-show 与 ng-if

转载 作者:行者123 更新时间:2023-11-28 12:31:14 27 4
gpt4 key购买 nike

ng-ifng-show 似乎工作相似。

<img src="spinner.gif" ng-if="showSpinner">


<img src="spinner.gif" ng-show="showSpinner">

他们之间有什么区别吗?有任何性能影响吗?如何决定在哪里正确使用它们?

最佳答案

ngIf differs from ngShow and ngHide in that ngIf completely removes and recreates the element in the DOM rather than changing its visibility via the display css property. A common case when this difference is significant is when using css selectors that rely on an element's position within the DOM, such as the :first-child or :last-child pseudo-classes.

http://docs.angularjs.org/api/ng/directive/ngIf

关于javascript - AngularJS 中的 ng-show 与 ng-if,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21965327/

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