gpt4 book ai didi

angular - `$color` 的参数 `opacity($color)` 必须是颜色

转载 作者:行者123 更新时间:2023-12-04 03:07:59 28 4
gpt4 key购买 nike

我正在尝试创建 Angular 2 主题,我按照网站上提到的教程进行操作。这是我的主题文件。

@import '~@angular/material/theming';

@include mat-core();
$primary: mat-palette($mat-deep-purple);
$accent: mat-palette($mat-amber, A200);
$theme: mat-light-theme($primary, $accent);

@include angular-material-theme($theme);

.m2app-dark {
$dark-primary: mat-palette($mat-blue, A800);
$dark-accent: mat-palette($mat-light-blue, A8008);
$dark-warn: mat-palette($mat-orange, A200);
$dark-theme: mat-dark-theme($dark-primary, $dark-accent, $dark-warn);
@include angular-material-theme($dark-theme);
}

在构建过程中我遇到异常

ERROR in ./node_modules/css-loader?{"sourceMap":false,"importLoaders":1}!./node_modules/postcss-loader?{"ident":"postcss"}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":false,"precision":8,"includePaths":[]}!./src/app-theme.scss
Module build failed:
undefined
^
Argument `$color` of `opacity($color)` must be a color

Backtrace:
node_modules/@angular/material/_theming.scss:1119, in function `opacity`
node_modules/@angular/material/_theming.scss:1119, in function `if`
node_modules/@angular/material/_theming.scss:1119, in function `mat-color`
node_modules/@angular/material/_theming.scss:1508, in mixin `mat-option-theme`
node_modules/@angular/material/_theming.scss:3798, in mixin `mat-core-theme`
node_modules/@angular/material/_theming.scss:3848, in mixin `angular-material-theme`
stdin:15
in C:\my-data\code\xenia\xenia-ui\node_modules\@angular\material\_theming.scss (line 1119, column 34)
Error:
undefined
^
Argument `$color` of `opacity($color)` must be a color

Backtrace:
node_modules/@angular/material/_theming.scss:1119, in function `opacity`
node_modules/@angular/material/_theming.scss:1119, in function `if`
node_modules/@angular/material/_theming.scss:1119, in function `mat-color`
node_modules/@angular/material/_theming.scss:1508, in mixin `mat-option-theme`
node_modules/@angular/material/_theming.scss:3798, in mixin `mat-core-theme`
node_modules/@angular/material/_theming.scss:3848, in mixin `angular-material-theme`
stdin:15
in C:\my-data\code\xenia\xenia-ui\node_modules\@angular\material\_theming.scss (line 1119, column 34)
at options.error (C:\my-data\code\xenia\xenia-ui\node_modules\node-sass\lib\index.js:291:26)
@ ./src/app-theme.scss 4:14-190
@ multi ./src/styles.css ./src/app-theme.scss

请让我知道我做错了什么。谢谢

最佳答案

您传递的第二个选项也应该是颜色代码。不同的颜色有不同的色码,任意随机数都行不通。完整列表可在此处找到 - https://material.io/design/color/#tools-for-picking-colors

所以在你的情况下,这两个都应该有效:

$dark-primary: mat-palette($mat-blue, A700);
$dark-primary: mat-palette($mat-blue, 800);

因为这两种都是公认的色调

关于angular - `$color` 的参数 `opacity($color)` 必须是颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47321817/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com