Angular6材质设计问题

时间:2019-06-24 13:04:55

标签: angular6

我正在研究angular6。最近安装了有关角形材料的库,并将其导入到适当的文件中,例如style.css

@import "~@angular/material/prebuilt-themes/indigo-pink.css";

app.module.ts中已导入,在app.component.html中也已导入

<md-checkbox>subscribe</md-checkbox>

但是在前端,我得到黑屏,而在控制台中,我得到了错误:

Uncaught TypeError: Object(...) is not a function
    at platform.es5.js:102
    at Module../node_modules/@angular/cdk/esm5/platform.es5.js (platform.es5.js:104)
    at __webpack_require__ (bootstrap:78)
    at Module../node_modules/@angular/cdk/esm5/a11y.es5.js (a11y.es5.js:1)
    at __webpack_require__ (bootstrap:78)
    at Module../node_modules/@angular/material/esm5/checkbox.es5.js (checkbox.es5.js:1)
    at __webpack_require__ (bootstrap:78)
    at Module../src/app/app.module.ts (app.component.ts:8)
    at __webpack_require__ (bootstrap:78)
    at Module../src/main.ts (main.ts:1)

2 个答案:

答案 0 :(得分:0)

我(很久以前)通过在angular.json中而不是styles.scss中包含样式来解决了这个问题:

"styles": [
    "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
    "src/sass/styles.scss"
],

答案 1 :(得分:0)

您似乎对AngularJS和Angular的Material感到困惑。

我认为您应该使用:<mat-checkbox>Subscribe</mat-checkbox>而不是md-checkbox

相关问题