添加 provideClientHydration 时从角度 15 迁移到角度 16 时出错

问题描述 投票:0回答:1

从 angular 15 迁移到 angular 16 后,使用 universal,如果我将 provideClientHydration 添加到我的 AppModule,我会得到错误

ERROR Error: When using the default fallback, a fallback language must be provided in the config!
    at getNextLangs (./node_modules/@ngneat/transloco/fesm2020/ngneat-transloco.mjs:318:19)
    at handleFailure (./node_modules/@ngneat/transloco/fesm2020/ngneat-transloco.mjs:898:67)
    at error (./node_modules/@ngneat/transloco/fesm2020/ngneat-transloco.mjs:568:25)
    at onError (./node_modules/rxjs/dist/cjs/internal/operators/catchError.js:13:51)
    at _error (./node_modules/rxjs/dist/cjs/internal/operators/OperatorSubscriber.js:43:21)
    at error (./node_modules/rxjs/dist/cjs/internal/Subscriber.js:60:18)
    at onError (./node_modules/rxjs/dist/cjs/internal/operators/tap.js:31:28)
    at _error (./node_modules/rxjs/dist/cjs/internal/operators/OperatorSubscriber.js:43:21)
    at error (./node_modules/rxjs/dist/cjs/internal/Subscriber.js:60:18)
    at <anonymous> (./node_modules/rxjs/dist/cjs/internal/operators/retry.js:60:36)

如果我将它添加到 AppServerModule 中也一样

import { NgModule } from '@angular/core';
import { ServerModule } from '@angular/platform-server';
import { provideClientHydration } from '@angular/platform-browser';

import { AppModule } from './app.module';
import { AppComponent } from './app.component';

@NgModule({
  imports: [
    AppModule,
    ServerModule,
  ],
  bootstrap: [AppComponent],
  providers: [provideClientHydration()]
})
export class AppServerModule {
}
angular angular-universal transloco
1个回答
0
投票

也许是库导致了错误。 Client hydration 目前不支持 i18n

https://angular.io/guide/hydration#i18n

或者如果只是一个组件,可以使用

@Component({
  ...
  host: {ngSkipHydration: 'true'},
})
class ExampleCmp {}

查看整个文档

https://angular.io/guide/hydration

祝你好运

© www.soinside.com 2019 - 2024. All rights reserved.