【发布时间】:2021-11-25 19:13:44
【问题描述】:
我正在与BootstrapVue 合作。我有以下问题 - 我的 parent.vue 中有一个选择下拉列表,我在其中选择我的 ID(你可以看到它是我的道具),我想将它与我的 json 文件进行比较...
现在我需要做以下事情:
- 使用我的 json 文件检查我选择的 ID(来自 parent.vue)并找到正确的 ID
- 将所有
Articel放入我的下拉选择中 - 将所选 Articel 的
Rank发送回父级
我不知道如何使用嵌套的 JSON 文件解决这个问题。我想我必须使用 v-for 循环。
提前感谢您帮助我!
我的代码:
<template>
<b-card>
<div class="mt-2">CLOTHING ITEM</div>
<b-form-select type="text"></b-form-select>
</b-card>
</template>
<script>
import json from './json/ID.json'
export default {
name: "customerChoice",
data() {
return {
json: json,
}
},
props: ["ID"]
}
</script>
我的嵌套 json:
[
{
"ID": "1111",
"Product": {
"1": {
"Articel": "Jeans",
"Rank": "1"
},
"2": {
"Articel": "T-Shirt",
"Rank": "2"
}
}
},
{
"ID": "2222",
"Product": {
"1": {
"Articel": "Hoodie",
"Rank": "2"
},
"2": {
"Articel": "Jeans",
"Rank": ""
}
}
},
{
"ID": "3333",
"Product": {
"1": {
"Articel": "Socks",
"Rank": "1"
}
}
}
]
【问题讨论】:
标签: javascript json vue.js vuejs2 bootstrap-vue