首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法从Angular 7中的材料主题获取变量

无法从Angular 7中的材料主题获取变量
EN

Stack Overflow用户
提问于 2018-10-28 03:00:29
回答 1查看 2.5K关注 0票数 3

我有Angular 7.0.3,我正在尝试用我的材料主题的原色创建scss变量

代码语言:javascript
复制
// src/styles/_variables.scss
@import "~@angular/material/theming";
@include mat-core();
$app-primary: mat-palette($mat-indigo);

但是得到这个错误

代码语言:javascript
复制
ERROR in ./src/app/app.component.scss
Module build failed (from ./node_modules/sass-loader/lib/loader.js):

undefined
            ^
      (50: #e8eaf6, 100: #c5cae9, 200: #9fa8da, 300: #7986cb, 400: #5c6bc0, 500: #3f51b5, 600: #3949ab, 700: #303f9f, 800: #283593, 900: #1a237e, A100: #8c9eff, A200: #536dfe, A400: #3d5afe, A700: #304ffe, contrast: (50: rgba(0, 0, 0, 0.87), 100: rgba(0, 0, 0, 0.87), 200: rgba(0, 0, 0, 0.87), 300: white, 400: white, 500: white, 600: white, 700: white, 800: white, 900: white, A100: rgba(0, 0, 0, 0.87), A200: white, A400: white, A700: white), default: #3f51b5, lighter: #c5cae9, darker: #303f9f, default-contrast: white, lighter-contrast: rgba(0, 0, 0, 0.87), darker-contrast: white, "50-contrast": rgba(0, 0, 0, 0.87), "100-contrast": rgba(0, 0, 0, 0.87), "200-contrast": rgba(0, 0, 0, 0.87), "300-contrast": white, "400-contrast": white, "500-contrast": white, "600-contrast": white, "700-contrast": white, "800-contrast": white, "900-contrast": white, "A100-contrast": rgba(0, 0, 0, 0.87), "A200-contrast": white, "A400-contrast": white, "A700-contrast": white, "contrast-contrast": null)
 isn't a valid CSS value.
      in C:\code\front\angular\speakup\node_modules\@angular\material\_theming.scss (line 1268, column 14)

我如何解决此问题,或者我需要向您提供有关我的设置的哪些其他信息?

EN

回答 1

Stack Overflow用户

发布于 2018-11-22 01:47:18

您是否在某处使用变量$app-primary作为CSS颜色值(例如color: $app-primary)?

在这种情况下,您需要使用map_get()来提取实际颜色值:

例如,color: map_get($app-primary, 900) <-第二个值是色调,请在@angular/material/_theming.scss中的$mat-indigo调色板中查看可能的值

另外:您将在_variable.scss中调用mat-core()。这使我认为您可能会不止一次调用mat-core()。别干那事!检出https://material.angular.io/guide/theming

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53025315

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档