scoped
屬性是 HTML5 中的新屬性。當style標簽擁有scoped屬性時,它的css樣式只能用于當前的Vue組件,可以使組件的樣式不相互污染。
如果一個項目的所有style標簽都加上了scoped屬性,相當于實現了樣式的模塊化。
1、全頁面覆蓋
不添加scoped
<style lang="less" >/deep/.hp-cell-content .ivu-tabs-content {height: calc(100vh - 6.5rem - 60px);}
</style>
2、單頁面樣式覆蓋
1、命名空間
<Cell class="cellSty" title="單元格樣式覆蓋" />
<style lang="less">.cellSty {.hp-cell-content .ivu-tabs-content {height: calc(100vh - 6.5rem - 60px);}}
</style>
2、穿透
<Cell title="單元格樣式覆蓋" />
<style lang="less" scoped>/deep/.hp-cell-content .ivu-tabs-content {height: calc(100vh - 6.5rem - 60px);}
</style>
總結:單頁面覆蓋iview樣式時,若采用自定義類名,不用添加
scoped
,使用穿透方式需要添加。