如果定義樣式的時候,內層樣式名稱和外層保持一致的話可以簡寫如下
如果一個樣式下有相關的其他樣式可以使用 &-xxx
來簡寫,
<template>
<div class="test-container">
<div class="test-container-header">header</div>
<div class="test-container-body">body</div>
<div class="test-container-footer">footer</div>
</div>
</template>
<script>
export default {
}
</script>
<style lang="scss">
.test-container {
background: pink;
height: 200px;
&-header {
font-size: 24px;
color: #67c23a;
}
&-body {
font-size: 24px;
color: #f56c6c;
}
&-footer {
font-size: 24px;
color: #909399;
}
}
</style>