【发布时间】:2022-12-02 12:31:15
【问题描述】:
I have the following data:
[...]
data() {
return {
theme: \"dark\",
data: {
ioa: [
{
title: \"xyz1\",
applications: [\"app1\",\"app2\",\"app3\"],
},
{
title: \"xyz2\",
applications: [\"app1\",\"app2\"],
},
],
applications: {
app1:{
name: \"app1\",
},
mastodon:{
app2: \"app2\",
},
app3:{
name: \"app3\",
},
}
}
}
},
[...]
<!--
First i loop thow the ioa array in data json object an print it with vues text template syntax
-->
<div v-for=\"item in data.ioa\">
{{ item.title }}
<!--
for every element i will loop again throw the applications array in this object.
-->
<div v-for=\"id in item.applications>
<!--
in \"id\" there is a specific name, that is also the json key of the application object in data.
But when i want to print the title my application will show nothing
-->
{{ data.applications.id.name }}
</div>
</div>
The Problem is that i can now access the \"application\" object, with the returned \"id\" in text template syntax
The browsers console says: \"Uncaught TypeError: data.applications.id is undefined\". I know there is a problem with \"id\" which is a string ... but i dont know how to solve this.
I want to get the value of \"application\" json object, based on the return id value from data.ioa json object
标签: javascript vue.js