gpt4 book ai didi

http - 类型 'Http' 的参数不可分配给 Ionic ngx-translate 中类型 'Http' 的参数

转载 作者:可可西里 更新时间:2023-11-01 15:08:41 24 4
gpt4 key购买 nike

我正在开发 Ionic 2 移动应用程序并想使用 ngx-translate 功能。按照教程,我将像这样在应用程序模块中导入必要的文件:

import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { HttpModule, Http } from '@angular/http';
...

export function createTranslateLoader(http: Http) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}

给出了错误:

 Argument of type 'Http' is not assignable to parameter of type 'Http'.
Property 'handler' is missing in type 'Http'

我认为 ngx-translate 预期的包不匹配,但我不知道是什么以及如何。我的@angular/http 版本是 4.3.2有人知道该怎么做吗?

最佳答案

问题是由于版本冲突,也许你安装了“@ngx-translate/http-loader”的“^1.0.2”版本,尽管你的功能适用于以前的版本。不用担心!你只需要使用 HttpClient 而不是 Http ..

不要忘记更改“deps”常量的值并将 HttpClientModule 导入您的模块(或您的 app.module)

don't forget to change the value of 'deps' constant and import the HttpClientModule in your module (or in your app.module)

关于http - 类型 'Http' 的参数不可分配给 Ionic ngx-translate 中类型 'Http' 的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45372318/

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