Answer the question
In order to leave comments, you need to log in
How to form such an array of data from the selected checkboxes?
example here
"filters": [
{
"type": "checkbox",
"title": "Пол",
"filterData": {
"variants": [
{
"key": 14,
"value": "Мужской"
},
{
"key": 15,
"value": "Женский"
}
]
},
"filterId": 1
},
{
"type": "checkbox",
"title": "num",
"filterData": {
"variants": [
{
"key": 2,
"value": "345"
},
{
"key": 1,
"value": "123"
}
]
},
"filterId": 2
}
]
[
{ "filterId": 1, values: [14,15]},
{ "filterId": 2, values: [1]},
]
Answer the question
In order to leave comments, you need to log in
The user selects several of these checkboxes and presses the "Select" button.
selected() {
return this.filters.map(n => ({
filterId: n.filterId,
values: n.filterData.variants.filter(m => m.checked).map(m => m.key)
}));
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question