Vue控制台报错Uncaught (in promise) TypeError: Cannot read property 'instructor' of undefined at eval

Vue控制台报错Uncaught (in promise) TypeError: Cannot read property 'instructor' of undefined at eval
代码如下

ajax.POST('login', loginData) // axios里data与params区别
            .then(function (res) {
              that.loginStatus.loading = false
              if (res.data['instructor'] === 'instructor') {
                roleInfo.role = 'instructor'
              }

php代码

public function login () {
            $dataArr = request()->param();
            $role = $dataArr['role'];
            $instructor = '';
            if ($role === 'admin') {
                $selectSql = "select admin_username as fullname,password from beta_administrator where admin_username = ?";
            } elseif ($role === 'student') {
                $selectSql = "select stu_name as fullname,password from beta_student where stu_number = ?";
            }else {
                $selectCounselorSql = "select * from beta_instructor where ins_number = ?";
                $selectCounselorRes = Db::query($selectCounselorSql, [$dataArr['username']]);//获取结果集
                $vs = check_before_add_data($selectCounselorRes);//判断结果集是否为空
                if ( $vs === 1 ){
                    $instructor = 'instructor';
                }
                $selectSql = "select tea_name as fullname,password from beta_teacher where tea_number = ?";
            }
            $selectRes = Db::query($selectSql, [$dataArr['username']]);
            $v = check_before_add_data($selectRes);
            if ($v === 1) {
                if ($selectRes[0]['password'] === $dataArr['password']) {
                    return_json(['fullName' => $selectRes[0]['fullname'],'instructor' => $instructor], 'ok', 200);
                } else {
                    return_json('','账户或密码错误',400);
                }
            } elseif ($v === 0) {
                return_json('','用户名不存在',400);
            } else {
                return_json('','登录失败,未知错误',400);
            }

        }
}

请求大神指正

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐