Angular 10 中的树摇晃正在“摇晃”我的 AsyncPipe。
Angular 10的发行说明博客条目引入了一种新--strict模式ng new:
这样做的一件事是:
将您的应用程序配置为无副作用以启用更高级的摇树
官方文档说:
当您使用严格模式创建项目和工作区时,您会注意到位于 src/app/ 目录中的额外 package.json 文件。该文件通知工具和打包器该目录下的代码没有非本地副作用。
这是其中的内容package.json:
{
"name": "heroes",
"private": true,
"description_1": "This is a special package.json file that is not used by package managers.",
"description_2": "It is used to tell the tools and bundlers whether the code under this directory is free of code with non-local side-effect. Any code that does have non-local side-effects can't be well optimized (tree-shaken) and will …Run Code Online (Sandbox Code Playgroud) 当尝试访问holidayEntries$: Observable<HolidayEntry[]>html 中的可观察对象时,例如
<ion-list lines="full" *ngFor="let holiday of holidayEntries$ | async">
<ion-label>
<h1>{{ holiday.author }}</h1>
</ion-label>
</ion-list>
Run Code Online (Sandbox Code Playgroud)
我总是收到以下错误:
core.js:6228错误错误:未捕获(承诺中):
错误:找不到管道“异步”!
我已经读到CommonModule可能会丢失,就像这里提到的那样,但我将其导入到相应的.module.ts文件中。
知道我做错了什么吗?
编辑: 我的模块
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
HolidaysPageRoutingModule
],
declarations: [HolidaysPage]
})
export class HolidaysPageModule {}
Run Code Online (Sandbox Code Playgroud)
我的组件
@Component({
selector: 'app-tab2',
templateUrl: './holidays.page.html',
styleUrls: ['./holidays.page.scss'],
})
export class HolidaysPage implements OnInit {
currentUser$: Observable<UserVM>;
holidayEntries$: Observable<HolidayEntry[]>;
constructor(
private readonly appStore: Store<fromApp.State>,
private readonly holidayStore: Store<fromHoliday.State>) {
this.currentUser$ = appStore.select(fromAuth.selectAuthUser).pipe(
map(user …Run Code Online (Sandbox Code Playgroud)