element-plus中el-dialog使用::v-deep()穿透设置样式不生效踩坑记录

场景:

html 复制代码
    <el-dialog
      v-model="dialogVisible"
      width="50%"
      :before-close="beforeClose"
      append-to-body
      draggable
      center
      title="标题"
    >
    <template #footer>
        <span class="dialog-footer">
          <el-button type="primary" @click="handlePublish">确 定</el-button>
          <el-button @click="beforeClose">取 消</el-button>
        </span>
      </template>
    </el-dialog>
    <style scope>
    ::v-deep(.el-dialog__header) {
	    border-bottom: none;
 	 }
 	::v-deep(.el-dialog__body) {
   	 padding: 20px 20px 0;
 	 }
  	::v-deep(.el-dialog__footer) {
  	  padding: 10px 20px 20px;
   	 border-top: none;
 	 }
    </style>

如上:我想去掉插槽自带的下边框和上边框,但是不生效。

解决方案

给el-dialog加个类,在不带scope的<style></style>中设置样式,如下:

html 复制代码
    <el-dialog
      class="tip-dialog"
    >
    </el-dialog>

样式:

css 复制代码
<style lang="scss">
.tip-dialog {
  .el-dialog__header {
    border-bottom: none;
  }
  .el-dialog__body {
    padding: 20px 20px 0;
  }
  .el-dialog__footer {
    padding: 10px 20px 20px;
    border-top: none;
  }
}
</style>

这样就好了。

相关推荐
-今昭-21 小时前
Logstash 管理
java·服务器·前端
名字还没想好☜1 天前
React 用自定义 useDebounce Hook 治好搜索框频繁请求:防抖、竞态取消与卸载清理
前端·javascript·react.js·react·hooks
杉氧1 天前
Flutter 跨平台多端适配与 Android/iOS 一键自动化打包发布
android·前端·flutter
障碍的枫子1 天前
xss和CSRF的攻击和防御
前端·xss·csrf
用户921080262861 天前
3. 给 Bubble 新增一个 Agent Variant
前端
抓不住时间的沙1 天前
butterfly主题美化,打造属于自己的个性博客
java·开发语言·前端·javascript·node.js·github
kyriewen1 天前
前端切图仔被 AI 新闻淹死的第 N 天,我用 TRAE Work 定时任务救了自己
前端·人工智能·trae
京东云开发者1 天前
【全栈实践】第一个 AI Agent 项目:从零搭建 AI 音频创作助手(高级篇)
前端·agent·音视频开发
AbrahamCS1 天前
从角色协同到可运行图:Graph Engineer 与多智能体编排
前端·人工智能·智能体
BigTopOne1 天前
VS Code IntelliSense 配置(解决 #include 找不到的报红)
前端