【发布时间】:2022-01-14 07:13:42
【问题描述】:
【问题讨论】:
-
您是否介意从图片中提取代码并将其作为文本粘贴到您的问题中?
【问题讨论】:
:root {
--bs-light: #f1f2f3;
--bs-dark: #3e3e3c;
}
export enum ScssVariables {
Light = "light",
Dark = "dark",
}
@Directive({
selector: "[test-attr]",
})
export class TestDirective {
public styles: { [key in ScssVariables]: string | null } = {
light: null,
dark: null,
};
constructor() {
const styles = window.getComputedStyle(document.body);
Object.keys(this.styles).forEach((key: ScssVariables) => {
this.styles[key] = styles.getPropertyValue("--bs-" + key);
})
console.log(this.styles);
}
}
【讨论】: