【发布时间】:2021-01-07 23:02:07
【问题描述】:
为什么 Object.assign 在 Localhost 上可以正常工作,但在服务器上却不行?
我的 vue 应用托管在 S3 上,除了 Object.assign 之外一切正常。
远程 api 被正确调用并且更新正常,但是对象没有被分配并且我在 catch 中得到一个空错误。 console.log(JSON.stringify(e)) 的日志只是 {}。
axios
.put(this.url + "/client/" + item.id, {
name: item.name,
contactName: item.contactName,
phoneNumber: item.phoneNumber,
email: item.email,
})
.then((response) => {
Object.assign(this.client[this.editedIndex], item);
})
.catch((e) => {
console.log(JSON.stringify(e));
this.dialogError = true;
});
},
我曾尝试像 this Object.assign({}, this.client[this.editedIndex], item); 那样更改对象分配,但出现任何意外行为。
【问题讨论】:
-
如果您在 catch 日志中看到一个空错误,那么您可以确定 Object.assign 是。也许将 console.log(JSON.stringify(e)) 更改为 console.error(e);得到真正的错误信息。也许 then 函数引发了一个看不见的 javascript 错误,也许是网络请求失败。
标签: javascript vue.js axios