我试图在.ts
文件中导入scss样式:
import style from "./map.scss";
此文件包含:
.Map {
z-index: 1;
position: absolute;
}
我收到消息:
map.scss“'没有默认导出。
我想在Ts中使用此CSS属性,例如:
DOMFunction.createElement("div",{ id: "map", class: style.Map });
style.Map
是我需要的财产
答案 0 :(得分:1)
如果要导入.scss
文件,则应将其包括在全局样式表中:
styles.scss:
@import url('./map.scss');
更新:
如果要在Typescript中访问SASS值(variables.scss中的$ colors),请you can read here
或者,您可以使用ngStyle
自行设置样式:
<div [ngStyle]="{ 'width': 'calc(100% - ' + yourVariable + 'px)' }"></div>