【发布时间】:2018-04-29 13:25:29
【问题描述】:
当平台特定的 CSS 文件发挥作用时,我对样式有疑问。
查看以下文件:
items.component.ts:
@Component({
selector: 'ns-items',
moduleId: module.id,
template: `
<Label [nsRouterLink]="['/item', item.id]" [text]="item.name"
class="list-group-item"></Label>
`,
styleUrls: ['./items.component.css' ]
})
export class ItemsComponent implements OnInit {
items: Item[];
constructor(private itemService: ItemService) {
}
ngOnInit(): void {
this.items = this.itemService.getItems();
}
}
items.component.css:
Label {
background-color: blue;
}
items.component.ios.css:
Label {
background-color: red;
}
items.component.android.css 为空。
在 iOS 上,它的行为符合预期,Labels 背景颜色为红色。
在 Android 上,Labels 背景颜色完全没有变化。我期望的行为是它继承了 items.component.css 的样式,因此 Labels 的背景颜色应该是蓝色,但它不是。
我尝试在items.component.android.css 中添加@import items.component.css,但随后我收到Maximum call stack size exceeded 错误,因为我在组件中声明了CSS。
拥有组件全局 CSS 以及从组件全局 CSS 继承的平台特定 CSS 的正确方法是什么?还是我做错了什么?
【问题讨论】:
标签: angular nativescript angular2-nativescript