• Vue ElementUI 修改消息提示框样式—messageBox 的大小


    在窄屏模式下(移动端或pda),提示框的宽度太宽,会出现显示不完全的问题。 应当如何修改 ElementUI 的样式呢?

    在这里插入图片描述

      open() {
          this.$confirm(
            window.vm.$i18n.t("tips.conLogOut"),
            window.vm.$i18n.t("tips.tip"),
            {
              confirmButtonText: window.vm.$i18n.t("backTips.confirm"),
              cancelButtonText: window.vm.$i18n.t("backTips.cancel"),
              type: "warning",
            }
          ).then(() => {
            this.logout();
          });
        },
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
     
    
    • 1
    • 2
    • 3
    • 4
    • 5

    在这里插入图片描述
    此时在scoped的style中写是无效的,因为ElementUI组件不可以给样式添加scoped,因此必须去掉scoped;但是去掉scoped后不满足单组件的CSS。

    解决方案

    1、附加在没有scoped的style中

    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    在这里插入图片描述
    2、给消息提示框加类名(荐)
    更加推荐这个messageBox添加一个类名,比较好用并且不会影响到其他页面的弹框样式。
    在这里插入图片描述

    this.$confirm('确认注销吗?', '提示', {
      customClass: 'elmessageWidth'
    }).then(() => {
      this.$message({
        message: '已成功注销',
        type: 'success'
      })
    }).catch(() => {  })
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    或者直接important

    @media (max-width: 730px) {
      .elmessageWidth{
        width: 350px !important;
      }
     }
    
    • 1
    • 2
    • 3
    • 4
    • 5

    在这里插入图片描述

  • 相关阅读:
    Java入门教程(14) ——Scanner 获取键盘输入
    数据结构——线性表之顺序表
    C语言结课实战项目_贪吃蛇小游戏
    【k8s金牌知识】k8s升级攻略
    数据可视化ECharts:静态页面制作--主体
    安全在编程这个行业中的困境【系统工程师的思考】
    接口测试总结分享(http与rpc)
    stack和queque
    Spring Security配置个过滤器也这么卷
    Web3失败下互联网的未来转型之路
  • 原文地址:https://blog.csdn.net/Maxueyingying/article/details/136296896