2 回答
TA贡献1865条经验 获得超7个赞
尝试执行此操作,如果中有多个对象meetups,则可以使用Array.map遍历对象数组,并在其中打印出该title属性的值interval。
this.meetups.map(obj => {
console.log(`title: ${obj['interval']['title']}`);
});
还是简单地说,如果其中只有1个对象meetups?
this.meetups[0]['interval']['title']
演示:
const meetups =[{"id":"-12345","title":"abcds","description":"Hello3","date":"2023-12-29","location":{"color":"grey darken-2","icon":"not_interested","id":"none","title":""},"creatorId":"abcd1234","time":"24:00","color":{"color":"red darken-2","id":"06","title":"Ret"},"interval":{"color":"green darken-2","icon":"local_activity","title":"Weekly","value":3},"statusType":false,"pause":false,"pushNotification":false}];
meetups.map(obj => {
console.log(`title: ${obj['interval']['title']}`);
});
关于您在问题中提供的代码,我不确定您为什么要使用Array.filter(),因为它的作用是基于您提供的回调函数返回一个新数组filter()
。此外,使用JSON.stringify()对其进行字符串化处理会将该数组转换为字符串,这违背了访问对象数组中的值的目的。
添加回答
举报