我在 Angular 14 中使用 trackBy 和 strict-mode: true 时遇到问题,
这是代码(在严格模式下像 charme 一样工作: false)
应用程序组件.html:
<div *ngFor="let item of items; index as i; trackBy: trackByFn">
{{ i + 1 }} {{item.name}}
</div>
<br>
<button (click)="addSomething()">Load Data</button>
Run Code Online (Sandbox Code Playgroud)
应用程序组件.ts
import { Component } from '@angular/core';
interface DemoArray {
id: number;
name: string;
}
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {
title = 'angular-sandbox';
public items: DemoArray[] = [
{ id: 0, name: 'Apfel' },
{ id: 1, name: …Run Code Online (Sandbox Code Playgroud) Angular 16 推出了 Signals 作为开发者预览版。
当我想使用 Signals 时,是否必须关闭 zone.js。如果是这样,Signals 会自动从 zone.js 中完成这项工作吗?