我试过这样做:
this.elementRef.nativeElement.style['--config-use-images'];
和
document.documentElement.style.getPropertyValue('--config-use-images');
两者都不起作用。变量肯定存在。我可以在:root
下的开发工具中看到它。当我在控制台中登录时,第一个是未定义的,第二个是空字符串。
试试这个:
getComputedStyle(document.documentElement).getPropertyValue('--config-use-images')
或
getComputedStyle(this.elementRef.nativeElement).getPropertyValue('--config-use-images')