【Ionic】Argument of type“**Service”is not assignable to parameter of type 'RebirthHttp'.
来源:互联网 发布:增强网络安全意识 编辑:程序博客网 时间:2024/05/18 12:40
一、现象描述
Argument of type“**Service”is not assignable to parameter of type ‘RebirthHttp’.Property’http’ is missing in type ‘DataService’;
二、解决办法
原因是**Service.ts没有继承RebirthHttp;
在原来的**Service.ts基础上继承RebirthHttp即可;
原来的**Service:
@Injectable()export class DataService { }
现在的**Service.ts:
@Injectable()export class DataService extends RebirthHttp{ constructor(protected http: Http, jsonp: Jsonp, protected rebirthHttpProvider: RebirthHttpProvider, @Inject(EnvVariables) public envVariables) { super({ http, jsonp, rebirthHttpProvider }); }
这里,需要构造器构造Http,Jsonp,RebirthHttpProbider,并且注入EnvVariables;实现父类http,jsonp,rebirthHttpProvider;
这里的RebirthHttp接口如下(源代码):
//导包import { Http, Jsonp, Request, RequestOptions, RequestOptionsArgs } from '@angular/http';import { Observable } from 'rxjs/Observable';import 'rxjs/add/operator/map';import 'rxjs/add/operator/catch';//导出接口RebirthHttpInterceptor;export interface RebirthHttpInterceptor { request?: (option: RequestOptions) => RequestOptions | void;//请求 response?: (response: Observable<any>, request?: RequestOptions) => Observable<any> | void;}//导出声明类:RebirthHttpProvider;export declare class RebirthHttpProvider { private interceptors;//私有接口; constructor();//构造器; getInterceptors(): RebirthHttpInterceptor[];//获取接口; addInterceptor(interceptor: RebirthHttpInterceptor): RebirthHttpProvider;//添加接口; addRequestInterceptor(interceptor: (res: RequestOptions) => RequestOptions)://添加请求接口; RebirthHttpProvider; addResponseInterceptor(interceptor: (res: any) => any): RebirthHttpProvider;//添加响应接口 addResponseErrorInterceptor(interceptor: (res: any) => any): RebirthHttpProvider;//添加错误响应接口; handleRequest(req: RequestOptions): RequestOptions;//请求处理; handleResponse(res: Observable<any>, request?: RequestOptions): Observable<any>;//响应处理; baseUrl(host: string, excludes?: RegExp[]): RebirthHttpProvider;//基本Url; headers(headers?: {}): RebirthHttpProvider;//头们 json(): RebirthHttpProvider;//json;}//导出声明类RebirthHttp;export declare class RebirthHttp { protected http: Http; protected jsonp: Jsonp; protected rebirthHttpProvider: RebirthHttpProvider; constructor(option?: { http?: Http; jsonp?: Jsonp; rebirthHttpProvider?: RebirthHttpProvider; }); protected getBaseUrl(): string; protected getDefaultHeaders(): Object; protected requestInterceptor(req: RequestOptions): RequestOptions | void; protected responseInterceptor(res: Observable<any>, request?: RequestOptions): Observable<any> | void;}//导出声明类RebirthHttpService服务;export declare class RebirthHttpService { private http; private rebirthHttpProvider; enableJson: boolean; constructor(http: Http, rebirthHttpProvider: RebirthHttpProvider); request<T>(url: string | Request, options?: RequestOptionsArgs): Observable<T>; get<T>(url: string, options?: RequestOptionsArgs): Observable<T>; post<T>(url: string, body: any, options?: RequestOptionsArgs): Observable<T>; put<T>(url: string, body: any, options?: RequestOptionsArgs): Observable<T>; delete<T>(url: string, options?: RequestOptionsArgs): Observable<T>; patch<T>(url: string, body: any, options?: RequestOptionsArgs): Observable<T>; head<T>(url: string, options?: RequestOptionsArgs): Observable<T>; options<T>(url: string, options?: RequestOptionsArgs): Observable<T>; protected requestInterceptor(req: RequestOptions): RequestOptions | void; protected responseInterceptor(res: Observable<any>, request?: RequestOptions): Observable<any> | void; private handleRequest<T>(requestOptions);}//导出声明方法:BaseUrl:export declare function BaseUrl(url: string): <TFunction extends Function>(target: TFunction) => TFunction;//导出声明方法:默认头儿们;export declare function DefaultHeaders(headers: any): <TFunction extends Function>(target: TFunction) => TFunction;//导出声明变量:Path;export declare var Path: (key?: string) => (target: RebirthHttp, propertyKey: string | symbol, parameterIndex: number) => void;//导出声明变量:Query;export declare var Query: (key?: string) => (target: RebirthHttp, propertyKey: string | symbol, parameterIndex: number) => void;//导出声明变量:Body;export declare var Body: (target: RebirthHttp, propertyKey: string | symbol, parameterIndex: number) => void;//导出声明变量:Header;export declare var Header: (key?: string) => (target: RebirthHttp, propertyKey: string | symbol, parameterIndex: number) => void;//导出声明方法:头儿们export declare function Headers(headersDef: any): (target: RebirthHttp, propertyKey: string, descriptor: any) => any;//导出声明方法:Producesexport declare function Produces(producesDef: string): (target: RebirthHttp, propertyKey: string, descriptor: any) => any;//导出声明const:GETexport declare const GET: (url: string) => (target: RebirthHttp, propertyKey: string, descriptor: any) => any;//导出声明const:JSONPexport declare const JSONP: (url: string) => (target: RebirthHttp, propertyKey: string, descriptor: any) => any;//导出声明const:POSTexport declare const POST: (url: string) => (target: RebirthHttp, propertyKey: string, descriptor: any) => any;//导出声明const:PUTexport declare const PUT: (url: string) => (target: RebirthHttp, propertyKey: string, descriptor: any) => any;//导出声明const:DELETEexport declare const DELETE: (url: string) => (target: RebirthHttp, propertyKey: string, descriptor: any) => any;//导出声明const:HEADexport declare const HEAD: (url: string) => (target: RebirthHttp, propertyKey: string, descriptor: any) => any;////导出声明const:PATCHexport declare const PATCH: (url: string) => (target: RebirthHttp, propertyKey: string, descriptor: any) => any;//导出声明const REBIRTH_HTTP_PROVIDERSexport declare const REBIRTH_HTTP_PROVIDERS: Array<any>;
阅读全文
0 0
- 【Ionic】Argument of type“**Service”is not assignable to parameter of type 'RebirthHttp'.
- angular Argument of type '"price"' is not assignable to parameter of type 'string[]'
- 错误argument of type "char *" is incompatible with parameter of type "LPCWSTR"的解决方法
- 错误argument of type "char *" is incompatible with parameter of type "LPCWSTR"的解决方法
- 错误argument of type "char *" is incompatible with parameter of type "LPCWSTR"的解决方法
- 错误argument of type "char *" is incompatible with parameter of type "LPCWSTR"的解决方法
- 错误argument of type "char *" is incompatible with parameter of type "LPCWSTR"的解决方法
- 错误:argument of type "char *" is incompatible with parameter of type "LPCWSTR"
- TypeError: argument of type 'int' is not iterable
- Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node 解决办法
- No parameter name specified for argument of type
- Variable is not assignable (missing__block type specifier)
- Variable is not assignable (missing__block type specifier)
- Variable is not assignable (missing__block type specifier)
- Variable is not assignable (missing__block type specifier)
- object is not an instance of declaring class&argument type mismatch
- java.lang.IllegalStateException: Argument [RedirectAttributes] is of type Model
- expected 'float **' but argument is of type 'float (*)[5]'
- 未来数据分析市场走向预测
- Go语言开发工具
- iOS 11及iPhone X适配
- 3DMAX三维制作地形图教程
- Android学习,一些干货(1)
- 【Ionic】Argument of type“**Service”is not assignable to parameter of type 'RebirthHttp'.
- 218. The Skyline Problem
- 就从html开始说编程;
- 页面重用包含
- Android Studio 添加依赖
- 如何在GitHub For Windows软件上为代码库创建一个版本标签tags
- SpringMVC访问静态资源的三种方式
- LG R7
- 深度学习中简单神经网络的实现