访问数组内的对象 [英] Accessing Object inside Array

查看:45
本文介绍了访问数组内的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试访问Firebase array>对象内的值.

I'm trying to access values inside Firebase array > object.

当我尝试访问v-for中的值时,它会很好地工作.但是我不能这样做:postDetail.author.它返回未定义.有什么解决方案?

When I try to access values inside v-for, it works well. But I cannot do this: postDetail.author. It returns undefined. What's the solution?

推荐答案

由于postDetail是用于访问其对象内部属性的对象数组,因此您需要执行 postDetail [Index] .prop

Since postDetail is an array of object to access properties inside its objects, you need do something like postDetail[Index].prop

var postDetail =[{"author" : "abc", "meta" : "xyz"}];
console.log(postDetail[0].author);

这篇关于访问数组内的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆