Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从Typescript获取CSS参数_Css_Angular_Typescript_Sass_Angular8 - Fatal编程技术网

从Typescript获取CSS参数

从Typescript获取CSS参数,css,angular,typescript,sass,angular8,Css,Angular,Typescript,Sass,Angular8,是否有方法从ts文件中获取全局scss文件中设置的变量(8) 我希望在ts代码中定义的canvas元素中动态使用一些定义的变量 我想这回答了你的问题: TLDR: 不幸的是,无法直接从typescript/javascript代码访问SASS变量。但是,我们可以做一个变通方法来访问这些变量 您可以在上面提到的帖子中查看解决方法我认为这回答了您的问题: TLDR: 不幸的是,无法直接从typescript/javascript代码访问SASS变量。但是,我们可以做一个变通方法来访问这些变量 您可以

是否有方法从ts文件中获取全局scss文件中设置的变量(8)
我希望在ts代码中定义的canvas元素中动态使用一些定义的变量

我想这回答了你的问题:

TLDR:

不幸的是,无法直接从typescript/javascript代码访问SASS变量。但是,我们可以做一个变通方法来访问这些变量


您可以在上面提到的帖子中查看解决方法

我认为这回答了您的问题:

TLDR:

不幸的是,无法直接从typescript/javascript代码访问SASS变量。但是,我们可以做一个变通方法来访问这些变量


您可以在上面提到的帖子中查看解决方法

我有一种方法可以使用基于


在Global.SCSS中

@mixin ExportVariables($map, $prefix: null) {
  $mapPrefix: "--#{$prefix}";

  @if ($prefix){
    $mapPrefix: "#{$mapPrefix}-";
  }

  body {
    @each $name, $value in $map {
      #{$mapPrefix}#{$name}: $value;
    }
  }
}

--idle-state: #29ABE2;

// Import each of these in the theme service
$stateSCSS:(
  idle: var(--idle-state),
);
@include ExportVariables($stateSCSS, 'stateSCSS');
在职

const bodyStyles = window.getComputedStyle(document.body);

this.stateSCSS = {
  idle: bodyStyles.getPropertyValue('--stateSCSS-idle'),
};

我有一种方法可以使用基于


在Global.SCSS中

@mixin ExportVariables($map, $prefix: null) {
  $mapPrefix: "--#{$prefix}";

  @if ($prefix){
    $mapPrefix: "#{$mapPrefix}-";
  }

  body {
    @each $name, $value in $map {
      #{$mapPrefix}#{$name}: $value;
    }
  }
}

--idle-state: #29ABE2;

// Import each of these in the theme service
$stateSCSS:(
  idle: var(--idle-state),
);
@include ExportVariables($stateSCSS, 'stateSCSS');
在职

const bodyStyles = window.getComputedStyle(document.body);

this.stateSCSS = {
  idle: bodyStyles.getPropertyValue('--stateSCSS-idle'),
};