Skip to content

包含依赖关系的多个 Vue 文件之间的 样式覆盖问题 #13064

@KiKoRepub

Description

@KiKoRepub

Vue version

3.2.13

Link to minimal reproduction

I don't know what this should input

Steps to reproduce

A.vue 部分代码:
{

<h3>单文件组件</h3>
<!-- 引入 LifeCycle  -->
<life-cycle :title="666"/>

     import LifeCycle from './lifeCycle.vue';
    components:{
        LifeCycle,
   }

<style scoped>
    h3 {
       background-color: pink;
    }
</style>

}

LifeCycle.vue 代码:

    <h3>6666</h3>
    <h3>{{ title }}</h3>

    name:"LifeCycle",
     props:{
        title:{
            type:String,
            default:""
        }

<style >
    h3{
        background-color: green;
    }
</style>

What is expected?

标签的样式 会被覆盖 或者 非常规形式呈现

What is actually happening?

在项目运行后,对 lifeCycle.vue 中的 两个 H3 分别进行注释,剩余的那一个采用的样式 会很奇怪

具体如下:

  • 如果 两个都 不注释 ==> 两个 H3 背景均为 绿色
  • 如果先注释 6666 ,title 对应的 H3 背景为 粉色 ,此时放开 注释,两个都变为绿色
  • 如果 注释 title , 6666 对应的 H3 背景为 粉色,此时放开注释,两个都变为绿色

System Info

Any additional comments?

使用 props 接收数据 进行相关测试 的时候发现的

貌似是,如果是 只有 一个 H3 ,就会出现 上面的变成粉色的情况,两个 H3 或者 3个以上 就不会。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions