Angular 4 带材质 [英] Angular 4 with material

查看:33
本文介绍了Angular 4 带材质的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Angular4 实现Angular-Material".我从角度材料的官方网站 [angular.material.io][1]

I am trying to implement "Angular-Material" with Angular4. I made all setup from official site of angular material [angular.material.io][1]

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

[1]: https://material.angular.io/guide/getting-started but when trying to run project by npm start, getting following error:

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) &类型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) &类型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) &类型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) &类型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) &类型MdSliderBase' 不是构造函数类型.

node_modules/@angular/material/typings/button/button.d.ts(40,22): error TS2420: Class 'MdButton' incorrectly implements interface 'CanDisable'. Property 'disabled' is private in type 'MdButton' but not in type 'CanDisable'. node_modules/@angular/material/typings/button/button.d.ts(40,39): error TS2507: Type '(new (...args: any[]) => CanDisable) & typeof MdButtonBase' is not a constructor function type. node_modules/@angular/material/typings/checkbox/checkbox.d.ts(43,22): error TS2420: Class 'MdCheckbox' incorrectly implements interface 'CanDisable'. Property 'disabled' is missing in type 'MdCheckbox'. node_modules/@angular/material/typings/checkbox/checkbox.d.ts(43,41): error TS2507: Type '(new (...args: any[]) => CanDisable) & typeof MdCheckboxBase' is not a constructor function type. node_modules/@angular/material/typings/radio/radio.d.ts(24,22): error TS2420: Class 'MdRadioGroup' incorrectly implements interface 'CanDisable'. Property 'disabled' is missing in type 'MdRadioGroup'. node_modules/@angular/material/typings/radio/radio.d.ts(24,43): error TS2507: Type '(new (...args: any[]) => CanDisable) & typeof MdRadioGroupBase' is not a constructor function type. node_modules/@angular/material/typings/slide-toggle/slide-toggle.d.ts(14,22): error TS2420: Class 'MdSlideToggle' incorrectly implements interface 'CanDisable'. Property 'disabled' is missing in type 'MdSlideToggle'. node_modules/@angular/material/typings/slide-toggle/slide-toggle.d.ts(14,44): error TS2507: Type '(new (...args: any[]) => CanDisable) & typeof MdSlideToggleBase' is not a constructor function type. node_modules/@angular/material/typings/slider/slider.d.ts(26,22): error TS2420: Class 'MdSlider' incorrectly implements interface 'CanDisable'. Property 'disabled' is missing in type 'MdSlider'. node_modules/@angular/material/typings/slider/slider.d.ts(26,39): error TS2507: Type '(new (...args: any[]) => CanDisable) & typeof MdSliderBase' is not a constructor function type.

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

Somebody, please help me to fix above.

推荐答案

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

Double check your package.json dependencies and devDependencies file and find your typescript install. Make certain it is 2.2.0 or greater.

"typescript": "~2.2.0"

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

If you make a change, be sure to then run

$ npm update -D

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

If you have it installed globally and there is no typescript line in your package.json file, run

$ npm install -g typescript@2.2.0

这篇关于Angular 4 带材质的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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