相关疑难解决方法(0)

Angular 2:如何设置组件的主机元素?

我在Angular 2中有一个名为my-comp的组件:

<my-comp></my-comp>
Run Code Online (Sandbox Code Playgroud)

如何在Angular 2中设置此组件的主机元素的样式?

在Polymer中,您将使用":host"选择器.我在Angular 2中尝试过它.但它不起作用.

:host {
  display: block;
  width: 100%;
  height: 100%;
}
Run Code Online (Sandbox Code Playgroud)

我也尝试使用组件作为选择器:

my-comp {
  display: block;
  width: 100%;
  height: 100%;
}
Run Code Online (Sandbox Code Playgroud)

这两种方法似乎都不起作用.

谢谢.

css css-selectors angular-components angular

169
推荐指数
5
解决办法
12万
查看次数

标签 统计

angular ×1

angular-components ×1

css ×1

css-selectors ×1