【问题标题】:Angular 4 with materialAngular 4 带材质
【发布时间】:2017-10-13 21:17:06
【问题描述】:

我正在尝试使用 Angular4 实现“Angular-Material”。我从 angular material [angular.material.io][1] 官方网站进行了所有设置

[1]: https://material.angular.io/guide/getting-started 但尝试通过 npm start 运行项目时,出现以下错误:

node_modules/@angular/material/typings/button/button.d.ts(40,22): 错误 TS2420:“MdButton”类错误地实现了接口 '可以禁用'。属性“禁用”在“MdButton”类型中是私有的,但 不在“CanDisable”类型中。 node_modules/@angular/material/typings/button/button.d.ts(40,39): 错误 TS2507:类型 '(new (...args: any[]) => CanDisable) & typeof MdButtonBase' 不是构造函数类型。 node_modules/@angular/material/typings/checkbox/checkbox.d.ts(43,22): 错误 TS2420:类 'MdCheckbox' 错误地实现接口 '可以禁用'。 “MdCheckbox”类型中缺少属性“已禁用”。 node_modules/@angular/material/typings/checkbox/checkbox.d.ts(43,41): 错误 TS2507:类型 '(new (...args: any[]) => CanDisable) & typeof MdCheckboxBase' 不是构造函数类型。 node_modules/@angular/material/typings/radio/radio.d.ts(24,22): 错误 TS2420:“MdRadioGroup”类错误地实现接口 '可以禁用'。 “MdRadioGroup”类型中缺少属性“已禁用”。 node_modules/@angular/material/typings/radio/radio.d.ts(24,43): 错误 TS2507:类型 '(new (...args: any[]) => CanDisable) & typeof MdRadioGroupBase' 不是构造函数类型。 node_modules/@angular/material/typings/slide-toggle/slide-toggle.d.ts(14,22): 错误 TS2420:类“MdSlideToggle”错误地实现接口 '可以禁用'。类型中缺少属性“已禁用” 'MdSlideToggle'。 node_modules/@angular/material/typings/slide-toggle/slide-toggle.d.ts(14,44): 错误 TS2507:类型 '(new (...args: any[]) => CanDisable) & typeof MdSlideToggleBase' 不是构造函数类型。 node_modules/@angular/material/typings/slider/slider.d.ts(26,22): 错误 TS2420:“MdSlider”类错误地实现了接口 '可以禁用'。 “MdSlider”类型中缺少属性“已禁用”。 node_modules/@angular/material/typings/slider/slider.d.ts(26,39): 错误 TS2507:类型 '(new (...args: any[]) => CanDisable) & typeof MdSliderBase' 不是构造函数类型。

有人,请帮我解决上面的问题。

【问题讨论】:

  • 请正确重新排列问题中的内容。
  • 一个包坏了,它的永久状态在任何时候。不可能很快使用它们。

标签: angular angular-material2


【解决方案1】:

除了上面的答案,我还添加了 package.json 文件的截图:

转到您的 package.json 并检查依赖项和 devDependies,如下所示: package.json

第 1 步:如果 typescript 版本 低于 2.2.0 ,请将其更改为如图所示的最新版本。

第 2 步: 在终端中运行 npm update -D

Step3:要全局更新打字稿,请执行以下命令:

npm install -g typescript@version-number

【讨论】:

    【解决方案2】:

    仔细检查您的 package.json 依赖项和 devDependencies 文件并找到您的 typescript 安装。确保它是 2.2.0 或更高版本。

    "typescript": "~2.2.0"
    

    如果您进行更改,请确保然后运行

    $ npm update -D
    

    如果您已全局安装它并且您的 package.json 文件中没有 typescript 行,请运行

    $ npm install -g typescript@2.2.0
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-26
      • 1970-01-01
      • 2018-06-03
      • 2018-06-17
      • 1970-01-01
      • 2018-04-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多