2

我使用 Angular v6.1.2 并且只是启动公会后的初始项目。然后我在此链接https://www.npmjs.com/package/material-components-web之后添加 MDC ,

然后在我的 style.scss 文件中的项目中,我只是像这样导入 MDC scss

@import "~material-components-web/material-components-web";

然后我运行它向我显示此错误的应用程序

模块构建失败:@import "@material/button/mdc-button"; ^ 未找到或无法读取要导入的文件:@material/button/mdc-button。等等...

我尝试在angular.json下面的代码中添加路径,但它不起作用。

"stylePreprocessorOptions": {
    "includePaths": [
        "./node_modules/material-components-web", "./node_modules/@material"
    ]
}

还有什么我想念的吗?

4

1 回答 1

1
"stylePreprocessorOptions": {
    "includePaths": [
        "./node_modules"
    ]
}

只需包含在node_modules路径上,因为material-components-web并且@material需要知道父路径。

于 2018-08-18T13:31:19.507 回答