Vue的新手而不是Javascript的爱好者所以我有一个Vue组件,它使用Axios来获取控制台中的一些数据 . 我只是无法将代码输出到我的表单元素 .
所以我让Axios拦截响应并获取数据
methods: {
},
mounted: function() {
axios.interceptors.response.use(function (response) {
return response.data;
});
},
destroyed: function() {
}
}
所以它安装在页面加载和我的数据中
data() {
return {
formpersonaldetails: {},
title: this.results.title,
titleoptions: ['Mr', 'Mrs', 'Miss', 'Ms'],
fname: this.results.fname,
sname: this.results.sname,
dob: this.results.dob,
你猜哪个不起作用,所以我哪里错了?
响应如下:
{"id":2,"user_id":null,"fname":"Graham","sname":"Morby-Raybould","dob":"1982-07-10T08:22:00.000Z","gender":"Male","nationality":"British","mobile":null,"telephone":null,"hname":"","address2":"","address3":"","postcode":"","noktitle":"","nokfname":"","noksname":"","nokcontactnumber":"","nokhname":"","nokaddress2":"","nokaddress3":"","nokpostcode":"","emp_type":"","trade":"","ninumber":"","utrnumber":"","vatreg":null,"vatcert":"","created_at":"2017-10-10 08:22:37","updated_at":"2017-10-10 08:22:37"}
1 回答
您需要将
response
传递给function
:更多信息:Axios