Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.9k views
in Technique[技术] by (71.8m points)

vue 3.0 子组件使用了 teleport 标签,父组件使用 deep 样式穿透不生效

子组件:

<template>
  <teleport to="body">
    <div>
      <h4>示例</h4>
    </div>
  </teleport>
</template>

父组件:

<style lang="less" scoped>
:deep(h4) {
  color: red !important;
}
</style>

组件封装过程中突然发现的这个问题,请问有什么比较好的解决方法?

具体场景:子组件是弹窗基础公共组件,所以封装使用了teleport标签,默认to指向body,在父组件引用时有时会有微调内部样式的需求。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

自问自答吧,封装个disabled属性差不多就够用了

image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...