【发布时间】:2017-05-22 22:41:38
【问题描述】:
我想要一个干净的 HTML,只有组件内容而不是容器,因为我想使用 ITCSS 和 RSCSS 方法。
所以,我认为我有 2 个组件:app-simple-card 和 app-superior-header;我想要以下结构。
simple-card.component.scss
.simple-card {
> .header {
@extends .superior-header;
@extends .superior-header.-compact;
}
}
superior-header.component.scss
.superior-header {
> .title {}
&.-compact {}
}
问题
Angular 为组件内容呈现一个“容器”,迫使我使用组件名称作为选择器的一部分。这违反了 RSCSS 方法,所以我不想那样做,而且在另一个项目中重用样式会很糟糕。
现在,scss 文件如下所示:
.simple-card {
> app-superior-header > .header {...}
}
我也不想使用component as an attribute,因为它不能解决我的问题,and it's not considered a good practice。我需要完全删除/替换仅显示其内容的组件“容器”。
【问题讨论】: