gpt4 book ai didi

angular - 在生产版本中获取 ' Uncaught (in promise): Error: StaticInjectorError(a)[t]:' ....

转载 作者:行者123 更新时间:2023-12-02 16:06:41 28 4
gpt4 key购买 nike

Angular 6 应用程序在 ng 构建上运行良好。

但是在 ng build --prod 应用程序 UI 上加载,但在登录时我将从服务器获取正确的数据,之后我通过代码导航到仪表板页面 this.router.navigate(['/dashboard' ]); 我收到如下错误

错误错误:未捕获( promise ):错误:StaticInjectorError(a)[t]:StaticInjectorError(平台:核心)[t]:NullInjectorError:没有t的提供者!错误:StaticInjectorError(a)[t]:StaticInjectorError(平台:核心)[t]:NullInjectorError:没有t的提供者!在t.get(main.aa8ef128615c160bd861.js:1)在main.aa8ef128615c160bd861.js:1在t(main.aa8ef128615c160bd861.js:1)在t.get(main.aa8ef128615c160bd861.js:1)在main .aa8ef128615c160bd861。 js:1在t(main.aa8ef128615c160bd861.js:1)在t.get(main.aa8ef128615c160bd861.js:1)在Da(main.aa8ef128615c160bd861.js:1)在t.get(main.aa8ef128615c160bd861) .js:1 )在t.getToken(main.aa8ef128615c160bd861.js:1)在t.get(main.aa8ef128615c160bd861.js:1)在main.aa8ef128615c160bd861.js:1在t(main.aa8ef128615c160bd861.js:1) ) 在 t.get (main.aa8ef128615c160bd861.js:1)在main.aa8ef128615c160bd861.js:1在t(main.aa8ef128615c160bd861.js:1)在t.get(main.aa8ef128615c160bd861.js:1)在Da(main.aa) 8ef128615c160bd861.js: 1)在t.get(main.aa8ef128615c160bd861.js:1)在t.getToken(main.aa8ef128615c160bd861.js:1)在j(polyfills.9a5f6d04e0781d28c53e.js:1)在j(polyfills.9a5f6d04e0781d2) 8c53e.js:1)在polyfills.9a5f6d04e0781d28c53e.js:1在e.invokeTask(polyfills.9a5f6d04e0781d28c53e.js:1)在Object.onInvokeTask(main.aa8ef128615c160bd861.js:1)在e.invokeTask(polyfills.9a5f6d) 04e0781d28c53e.js:1) 在 t。 runTask (polyfills.9a5f6d04e0781d28c53e.js:1) at d (polyfills.9a5f6d04e0781d28c53e.js:1) at t.invokeTask [作为调用] (polyfills.9a5f6d04e0781d28c53e.js:1) at _ (polyfills.9a5f6) d04e0781d28c53e.js:1)

我的 App.module.ts 看起来像,

 import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { BsDatepickerModule } from 'ngx-bootstrap';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { HttpClientModule } from '@angular/common/http';
import { ChartsModule } from 'ng2-charts';

import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
import { MaterialModule } from './angular-material/material.module';
import { DashboardComponent } from './dashboard/dashboard.component';
import { AppRoutingModule } from './app.routing-module';
import { FiltersComponent } from './filters/filters.component';
import { SearchComponent } from './search/search.component';
import { ChartComponent } from './chart/chart.component';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { KeysPipe } from './shared/pipes/keys.pipe';
import { PdfViewerModule } from 'ng2-pdf-viewer';
import { AboutComponent } from './about/about.component';
@NgModule({
declarations: [
AppComponent,
HomeComponent,
DashboardComponent,
FiltersComponent,
SearchComponent,
ChartComponent,
KeysPipe,
AboutComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
ReactiveFormsModule,
MaterialModule,
ChartsModule,
HttpClientModule,
BsDatepickerModule.forRoot(),
AppRoutingModule,
PdfViewerModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

应用程序环境是:-

    Angular CLI: 6.0.8
Node: 10.2.1
OS: linux x64
Angular: 6.0.4
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

- 0.6.8, .6.8, .6.8, .6.8, -0.6.8, @angular/cdk -6.2.1, @angular/cli -6.0.8, @angular/material - 6.2.1, - 6.0.8, .6.8, - 0.6.8 , rxjs-6.2.1, typescript -2.7.2, webpack -4.8.3

最佳答案

我的一个组件中缺少提供程序,也遇到了同样的问题,为了更轻松地调试它,我建议这样做:

Enable the detailed output by going into angular.json file and editing the production: object so that: "aot": true , "optimization": false, "buildOptimizer": false.

这消除了构建过程中的丑化,因此错误日志包含丢失的模块名称

关于angular - 在生产版本中获取 ' Uncaught (in promise): Error: StaticInjectorError(a)[t]:' ....,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50836353/

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