1
我有以下錯誤:參數類型「HTTP」是不能分配給類型的參數「HTTP」
[ts] Argument of type 'Http' is not assignable to parameter of type 'Http'. Property '_backend' is protected but type 'Http' is not a class derived from 'Http'. (parameter) http: Http
此錯誤是在文件auth.module.ts
import { NgModule } from '@angular/core';
import { Http, RequestOptions } from '@angular/http';
import { AuthHttp, AuthConfig } from 'angular2-jwt'
import { AuthService } from './auth.service';
import { AuthGuard } from './auth.guard';
import { RoleGuard } from './role.guard';
import { GuestGuard } from './guest.guard';
export function authHttpServiceFactory(http: Http, options: RequestOptions) {
return new AuthHttp(new AuthConfig(), http, options);
}
@NgModule({
providers: [
AuthService,
AuthGuard,
RoleGuard,
GuestGuard,
{
provide: AuthHttp,
useFactory: authHttpServiceFactory,
deps: [Http, RequestOptions]
}
]
})
export class AuthModule {}
是什麼錯誤?
您使用的是angular和angular2-jwt的哪些版本? – jgranstrom
「angular2-jwt」:「^ 0.2.0」package.json https://pastebin.com/gYiqMV5m – Defus
我在代碼中看不到任何明顯的錯誤,但我看不到角度模塊的版本在你發佈的package.json中。您的角度模塊是否在版本2.4.2之前? – jgranstrom