我有两个数组
{
"products": [
{
"name": "Jivi",
"Hint": "45-60 IE/kg alle 5 Tage\n60 IE 1x/Woche\n30-40 IE 2 x/Woche",
"frequency": ["1", "2", "8"]
},
{
"name": "Adynovi",
"Hint": "40-50 IE/kg 2x/Woche im Abstand von 3-4 Tagen",
"frequency": ["2", "6", "7"]
},
{
"name": "Esperoct",
"Hint": "\"50 IE/kg \nalle 4 Tage\"\n",
"frequency": ["7"]
}
],
"haufigkeit" : [
{
"name": "1x / Woche",
"id": 1,
"value": 52.1428571429
},
{
"name": "2x / Woche",
"value": 104.2857142857143,
"id": 2
}
]
}
我有一个使用 Vuejsproducts.name
进行渲染的选择下拉菜单。
<select v-model="selectFrequency">
<option v-for="(level1,index) in dataJson.products"
v-bind:value="level1.frequency">{{level1.name}}</option>
</select>
例如,当我选择 时Jivi
,我想比较in和infrequency
中的数字以及它们匹配时,然后显示ofproducts
id
haufigkeit
name
haufigkeit
这是我正在尝试的
computed:{
selectFrequency:function(){
let results= this.haufigkeit.filter(array=>array.every(item => this.products.filter(group=>group.frequency.includes(item))));
}
}
我已经尝试了两天,它给了我一个错误cannot read property 'every' of undefined
。谁能建议我在哪里做错了?