类型'Http'的参数不能分配给Ionic ngx-translate中'Http'类型的参数 [英] Argument of type 'Http' is not assignable to parameter of type 'Http' in Ionic ngx-translate

查看:151
本文介绍了类型'Http'的参数不能分配给Ionic ngx-translate中'Http'类型的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一款Ionic 2移动应用,并希望使用ngx-translate功能。
按照教程,我在app模块中导入必要的文件,如下所示:

I'm developing an Ionic 2 mobile app and want to use ngx-translate features. Following the tutorial, I'm importing necessary files in app module like this:

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
有谁知道该怎么做?

I think there is a mismatch of packages expected by ngx-translate but i cannot figure out what and how. My @angular/http version is 4.3.2 Has anybody an idea what to do?

推荐答案

问题是由于冲突版本,您可能安装了^ 1.0x版本的@ ngx-translate / http-loader,但您的功能可用于以前的版本。别担心!你刚才使用的HttpClient而非http ..

the problem is due to a conflict version, maybe you installed a "^1.0.2" version of "@ngx-translate/http-loader" althought your function is available for a previous version. don't worry! you have just to use HttpClient instead of 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'的参数不能分配给Ionic ngx-translate中'Http'类型的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆