【发布时间】:2021-11-02 12:09:35
【问题描述】:
这个问题对我来说似乎是不可能的,但在这里
所以,我有一个关联数组,可以根据输入的过滤器进行更改(例如,如果某些过滤器打开,列可以消失或添加)。而且我还有一个带有动态“rowspan”的表(所以右侧的表可能很长),它是基于这个数组创建的。
{
"countries": {
"25": {
"title": "France",
"cities": {
"8954": {
"title": "Paris",
"languages": { <- here can add another object - "districts"
"16": {
"title": "English",
"quarters": {
"2_2020": {
"title": "% 2020-2021",
"parallels": {
"1": {
"title": "tst1"
},
"2": {
"title": "tst2",
"value": 7.89
},
"3": {
"title": "tst3",
"value": 37.2
},
"4": {
"title": "tst4",
"value": 9.16
},
"5": {
"title": "tst5",
"value": 6.45
}
}
},
"3_2020": {
"title": "% 2019-2020",
"parallels": {
"1": {
"title": "tst1"
},
"2": {
"title": "tst2",
"value": 8.59
},
"3": {
"title": "tst3",
"value": 9.1
},
"4": {
"title": "tst4",
"value": 6.8
},
"5": {
"title": "tst5",
"value": 75.1
}
}
}
}
},
"1000": {
"title": "Spanish",
"quarters": {
"2_2020": {
"title": "% 2020-2021",
"parallels": {
"1": {
"title": "tst1"
},
"2": {
"title": "tst2",
"value": 2.75
},
"3": {
"title": "tst3",
"value": 41.2
},
"4": {
"title": "tst4",
"value": 6.97
},
"5": {
"title": "tst5",
"value": 74.4
}
}
},
"3_2020": {
"title": "% 2019-2020",
"parallels": {
"1": {
"title": "tst1"
},
"2": {
"title": "tst2",
"value": 8.51
},
"3": {
"title": "tst3",
"value": 99.1
},
"4": {
"title": "tst4",
"value": 75.8
},
"5": {
"title": "tst5",
"value": 25.11
}
}
}
}
}
}
}
}
}
}
}
理想情况下,这个 json 看起来像 this 或(如果存在对象区)像 this
这是我的 vuejs 代码,用于仅使用另一个对象 -“区”创建表格主体
<b-tr v-for="(itemCountry, indexCountry) in itemsReal.countries" :key="indexCountry">
<b-tr v-for="(itemCities, indexCities) in itemCountry.cities" :key="indexCities" class="w-25 ">
<b-th class="w-25">{{ itemCities.title }}</b-th>
<b-tr v-for="(itemDistrict, indexDistricts) in itemCities.districts" :key="indexDistricts">
<b-td class="w-25 sticky-sidebar-district">{{ itemDistrict.title }}</b-td>
<b-tr class="language-rows" v-for="(itemLanguages, indexLanguages) in itemDistrict.languages" :key="indexLanguages">
<b-td class="language sticky-sidebar-language-District">{{ itemLanguages.title }}</b-td>
<b-tr class="d-inline-flex" v-for="(itemQuarter, indexQuarter) in itemLanguages.quarters">
<b-td v-for="(currentNumber, indexCurrentNumber) in itemQuarter.testsarr" :key="indexCurrentNumber" class="value-cells">
{{ currentNumber.value }} {{ currentNumber.value === undefined ? '­' : null }}
</b-td>
</b-tr>
</b-tr>
</b-tr>
</b-tr>
</b-tr>
【问题讨论】:
标签: javascript vue.js html-table