我是 Angular 的新手,我一直在看一些 youtube 視頻。其中一些使用“let item of items; let i as index ”,另一個使用“let item of items; let i = index ”。我試圖在谷歌搜索他們的差異,但我似乎無法找到一個簡單的答案。有人可以解釋粗體代碼有什么區別嗎?謝謝!
uj5u.com熱心網友回復:
它只是簡寫(縮小代碼),例如這段代碼
<li *ngFor="let item of items; index as i; trackBy: trackByFn">...</li>
是這個的簡寫代碼:
<ng-template ngFor let-item [ngForOf]="items" let-i="index" [ngForTrackBy]="trackByFn">
<li>...</li>
</ng-template>
所以基本上是一樣的:)
角檔案:鏈接
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/453925.html
標籤:有角度的 angularjs angularjs 指令 恩福
上一篇:參與開源專案很難嗎?
