我在试着装银栅。我看到了这个代码示例,但我不知道它们为什么使用两次.then。有人能帮我理解吗?谢谢
beforeMount() {
this.columnDefs = [
{headerName: 'Make', field: 'make'},
{headerName: 'Model', field: 'model'},
{headerName: 'Price', field: 'price'}
];
fetch('https://api.myjson.com/bins/15psn9')
.then(result => result.json())
.then(rowData => this.rowData = rowData);
}发布于 2018-10-26 08:09:35
因为您的response.json()调用本身返回另一个承诺,因为您可以阅读Body.json()。原因是响应体包含一个流,需要在使用它之前将其解析并转换为JS数据结构。
https://stackoverflow.com/questions/53001468
复制相似问题