elementui messageBox自定义弹窗的样式(若依)

背景

  • 在scoped中自定义样式之后:发现自定义样式没有生效
html 复制代码
<style scoped>
.custom-alert  {
  height: 300px; /* 你想要设置的高度 */
  overflow-y: auto;
}
</style>

解决方法

  • 新建一个style标签,不要加scoped
  • 样式生效了
html 复制代码
<style>
.custom-alert .el-message-box__message {
  height: 300px; /* 你想要设置的高度 */
  overflow-y: auto;
}
</style>

使用

在使用$alter的时候,使用 属性 customClass

js 复制代码
  this.$alert(response.msg, "导入结果", {
    dangerouslyUseHTMLString: true,
    customClass: 'custom-alert'
  });

延伸

  • 其实这个配置不只是用于$alert,其他的confirm什么的也可以用
  • 其实custom-alert 是整个 弹窗的样式,.el-message-box__message 后面才是消息的样式,这样就可以保证只改变消息内容区域的样式,按钮一直保持在下面
相关推荐
kyriewen36 分钟前
产品经理把PRD写成“天书”,我用AI半小时重写了一遍,他当场愣住
前端·ai编程·cursor
humcomm1 小时前
元框架的工作原理详解
前端·前端框架
canonical_entropy1 小时前
Attractor Before Harness: AI 大规模开发的方法论
前端·aigc·ai编程
zhangxingchao2 小时前
多 Agent 架构到底怎么选?从 Claude Agent Teams、Cognition/Devin 到工程落地原则
前端·人工智能·后端
IT_陈寒2 小时前
SpringBoot那个自动配置的坑,害我排查到凌晨三点
前端·人工智能·后端
Honor丶Onlyou2 小时前
VS Code 右键菜单修复记录
前端
卡卡军2 小时前
agmd 1.0 重磅升级——Rust 重写,性能起飞
javascript·rust
PILIPALAPENG2 小时前
Python 语法速成指南:前端开发者视角(JS 类比版)
前端·人工智能·python
Larcher2 小时前
🔥 告别抓瞎:用 Claude Code (cc) 优雅接手与维护已有项目
javascript·机器学习·前端框架
JYeontu2 小时前
轮播图不够惊艳?试下这个立体卡片轮播图
前端·javascript·css