从对象数组获取数据的问题-vue.js/API/axios/proxy



首先,我使用Vue.js使用axios和代理访问API的数据我试图访问嵌套在其他几个数组的最后一个数组中的对象的属性,但我有点碰壁了,详细信息如下:

全局详细信息

我正试图访问

我尝试过不同的方法,但这是我最近的尝试:

axios
.get(proxyurl + history_url, { 
reqHeaders
})
.then((reponse) => {
console.log(reponse.data)
this.lastItem = reponse.data.data.history[history.length-1]
console.log(this.lastItem)
this.lastEvol = this.lastItem.price
console.log(this.lastEvol)
})

这里的问题是;console.log(this.lastItem(";是:

lastItem答案

属性的值现在不同并且不正确。由于它显示";"代理";作为根对象名称,我认为这可能是问题所在,但我不确定。

我尝试了几种其他方法来访问此属性,但只出现了错误。

如有任何帮助,我们将不胜感激。

historyhistory.length表达式中未定义。试试这个:

.then((reponse) => {
const history = reponse.data.data.history;
console.log(reponse.data)
this.lastItem = history[history.length-1]
console.log(this.lastItem)
this.lastEvol = this.lastItem.price
console.log(this.lastEvol)
})

最新更新