axios 异步错误码,弹框提示:responseBusinessError.js

MessageBox 无效:

MessageBox.confirm 是个Promise, 没有 close 方法,点击取消会弹出多个

import {MessageBox,} from 'element-ui';

if (code === 50008) {
    // 去重新登录
    messageBox.push(MessageBox.confirm('您已注销,您可以取消停留在此页面,或重新登录', '确认注销', {
      confirmButtonText: '重新登录',
      cancelButtonText: '取消',
      type: 'warning',
    }).then(() => {
      toMDSLogin();
    }).catch(() => {
      messageBox.forEach((v) => {
        v.close();
      });
    }));
  }

解决:$confirm && vue.$msgbox.close();

import Vue from 'vue';
const vue = new Vue();


if (code === 50008) {
    vue.$confirm('您已注销,您可以取消停留在此页面,或重新登录', '确认注销', {
      confirmButtonText: '重新登录',
      cancelButtonText: '取消',
      type: 'warning',
    }).then(() => {
      toLogin();
    }).catch(() => {
      vue.$msgbox.close();
    });
  }

来源 https://blog.csdn.net/lazy_ting/article/details/108597773

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐