无法使用@HostBinding和阴影dom封装进行样式设置

问题描述

我有以下角度分量

@Component({
    selector: 'app-bar',templateUrl: './bar.component.html',styleUrls: ['./bar.component.scss'],encapsulation: ViewEncapsulation.ShadowDom,changeDetection: ChangeDetectionStrategy.OnPush
})
export class BarComponent {
    @Input() @HostBinding('class') cls;
}

所以我想,如果我将cls设置为“隐藏我”,则会将其隐藏。我在bar.component.scss中添加了以下内容:

:host {
    &.hide-me {
       display:  none;
    }
}

DEMO

这没有任何作用,它与影子dom封装有关。如果删除该行,它将再次按预期工作。有什么建议为什么shadowDom不再起作用?并且有一种方法可以通过启用影子dom来解决此问题;)

解决方法

更改您的scss以使其正常工作

In file included from src_c/gfxdraw.c:33:
In file included from src_c/pygame.h:32:
src_c/_pygame.h:216:10: fatal error: 'SDL.h' file not found
#include <SDL.h>
         ^~~~~~~
1 error generated.
---
For help with compilation see:
    https://www.pygame.org/wiki/MacCompile
To contribute to pygame development see:
    https://www.pygame.org/contribute.html
---
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1:
/Library/Frameworks/Python.framework/Versions/3.8/bin/python3 -u -c 'import sys,setuptools,tokenize; sys.argv[0] = '"'"'/private/var/folders/3m/w8365k4s59qfzct1l8ph77fh0000gn/T/pip-
install-oijhzzti/PyGame/setup.py'"'"';
__file__='"'"'/private/var/folders/3m/w8365k4s59qfzct1l8ph77fh0000gn/T/pip-install-
oijhzzti/PyGame/setup.py'"'"';f=getattr(tokenize,'"'"'open'"'"',open).
(__file__);code=f.read().replace('"'"'\r\n'"'"','"'"'\n'"'"');f.close();exec(compile(code,__file__,'"'"'exec'"'"'))' install --record
/private/var/folders/3m/w8365k4s59qfzct1l8ph77fh0000gn/T/pip-record-598hwe63/install-
record.txt --single-version-externally-managed --compile --install-headers
/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/PyGame Check the logs
for full command output.

有关更多信息,请参考this question

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...