switch语句里面使用break,return

break是直接退出switch语句
return是退出该函数 也就是switch语句块后面的语句也不执行了

switch (+ErrorCode) {
    
    
        case 210: // 请输入验证码
        case 211: // 验证码无效
          this.$msgbox({
    
    
            title: "hint",
            type: 'info',
            message: "这是info"
          });
          return;
        case 212: // 验证码已过期
          break;
        case 40850: // 用户名密码错误且需要验证码
          this.$msgbox({
    
    
            title: "hint",
            type: 'info',
            message: "这是info"
          });
          return false;
        default:
          break;
      }

猜你喜欢

转载自blog.csdn.net/weixin_43131046/article/details/126610341
今日推荐