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 后面才是消息的样式,这样就可以保证只改变消息内容区域的样式,按钮一直保持在下面
相关推荐
niucloud-admin1 小时前
web 端前端
前端
摘星编程4 小时前
React Native for OpenHarmony 实战:Linking 链接处理详解
javascript·react native·react.js
胖者是谁4 小时前
EasyPlayerPro的使用方法
前端·javascript·css
EndingCoder4 小时前
索引类型和 keyof 操作符
linux·运维·前端·javascript·ubuntu·typescript
liux35284 小时前
Web集群管理实战指南:从架构到运维
运维·前端·架构
沛沛老爹4 小时前
Web转AI架构篇 Agent Skills vs MCP:工具箱与标准接口的本质区别
java·开发语言·前端·人工智能·架构·企业开发
摘星编程5 小时前
React Native for OpenHarmony 实战:ImageBackground 背景图片详解
javascript·react native·react.js
小光学长5 小时前
基于Web的长江游轮公共服务系统j225o57w(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
前端·数据库
摘星编程6 小时前
React Native for OpenHarmony 实战:Alert 警告提示详解
javascript·react native·react.js
Joe5566 小时前
vue2 + antDesign 下拉框限制只能选择2个
服务器·前端·javascript