m0_65946416
2022-06-15 13:13
采纳率: 50%
浏览 70
已结题

vue怎么获取后端数据

后端程序
@RequestMapping("{phone}")
public Result sendCode(@PathVariable String phone) throws BaseException {
//判断手机号是否符合格式
if (!phone.matches(Constants.RegConstant.PHONE_REGSTR)) {
throw new BaseException(ResultEnum.PHONE_ERROR);
}

    userService.sendCode(phone);
    return new Result(true, StatusCode.OK,"发送成功",null);
}

我在前端
this.postRequest("api/register/"+this.codeType,{"phone":this.phone,"codeType":this.codeType}).then(resp=>{
if(resp && resp.data.flag==true){
this.phone=resp.phone;
this.codeType=resp.code;
var path = this.$route.query.redirect;
this.$router.replace({path: path == '/' || path == undefined ? '/home' : path});
}else{
this.$message.error("手机号码或验证码错误");
}
});
该怎么获取phone和code

3条回答 默认 最新

相关推荐 更多相似问题