vue-resource怎么获取返回的data?

像jquery的ajax从后台获取数据时,可以直接data.msg,但是用这个vue-resource该怎么读取到返回的msg字符串呢?就是下方“登录失败”四个字,想替换成类似data.msg的东西,该怎么做呢?

methods: {
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        var data = {
                            _token: "lKwaNM6vINbPsPWHFAX9fnDxCIWc73FGikUSRnq31",
                            username:this.ruleForm2.pass,
                            password:this.ruleForm2.checkPass
                        };
                        this.$http.post('/secure/signIn', data).then((response) => {
                            //success
                            this.$message({
                                message: '登录成功!',
                                type: 'success',
                                duration: '1000'
                            });
                            window.location.href = "http://test.administer/index#/homepage";
                        }, (response) => {
                            //failed
                            this.$message({
                                message: "登录失败",
                                type: 'error',
                                duration: '1200'
                            });
                        });
                    } else {
                        return false;
                    }
                });
            }
        }
阅读 3k
1 个回答
methods: {
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        var data = {
                            _token: "lKwaNM6vINbPsPWHFAX9fnDxCIWc73FGikUSRnq31",
                            username:this.ruleForm2.pass,
                            password:this.ruleForm2.checkPass
                        };
                        this.$http.post('/secure/signIn', data).then((response) => {
                            //success
                            this.$message({
                                message: '登录成功!',
                                type: 'success',
                                duration: '1000'
                            });
                            window.location.href = "http://ikeeko.administer/index#/homepage";
                        }, (response) => {
                            //failed
                            this.$message({
                                message: response.data.msg,
                                type: 'error',
                                duration: '1200'
                            });
                        });
                    } else {
                        return false;
                    }
                });
            }
        }
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题