我在一个conponents中添加一个方法,读取某个对象数组的数据,但是浏览器返回undefined
getFooterContent(){
return this.homepageService
.getFooter()
.then(content => this.footerContent = content)
.catch(error => this.error = error);
}
ngOnInit(){
this.getFooterContent();
console.log(this.footerContent);
}
this.footerContent 在浏览器中返回的值是
[Object, Object, Object, Object, Object]
0
:
Object
1
:
Object
2
:
Object
3
:
Object
4
:
Object
length
:
5
__proto__
:
Array[0]
但是无法读取里面对象的属性
转换一下就可以了。 了解一下JSON.Parse 跟 JSON.stringity