【发布时间】:2020-09-12 03:05:17
【问题描述】:
我目前正在学习 Vue,但无法摆脱范围问题。
问题:
profile.vue 样式继续覆盖来自 sidebar.vue 的样式。使用此设置,侧边栏应保持红色背景,而个人资料页面中的部分应为蓝色。不应该在style 标记这个工作中做scoped 吗?
Profile.vue 下方:
<template>
<main>
<section>
Test
</section>
<Sidebar></Sidebar>
</main>
</template>
<script>
import Sidebar from "../../components/sidebar/Sidebar";
export default {
name: "Profile",
components: {Sidebar}
}
</script>
<style scoped lang="scss">
main {
width: 100%;
@include flex();
section {
width: 100%;
background: blue;
margin-left: $size*5;
}
}
</style>
Sidebar.vue 下方:
<template>
<section>
Test
</section>
</template>
<script>
export default {
name: "Sidebar"
}
</script>
<style scoped lang="scss">
section {
max-width: ($size*45);
width: 100%;
background: red;
}
</style>
【问题讨论】: