this.$router.push({
query: {
...this.$route.query,
[itemNameParent]: 1 2 4,
},
})
function concatenateFieldValue(previous, value) {
if (typeof value !== 'string')
value = String(value);
if (!previous)
return value;
const uniqueValues = splitFieldValues(previous);
uniqueValues.add(value.trim());
return [...uniqueValues].join(' ');
}
function splitFieldValues(values) {
return new Set(values.split(' ').filter(Boolean));
}
function getUpdatedQuery(query, field, value) {
return {
...query,
[field]: concatenateFieldValue(query[field], value)
}
}
this.$router.push({
query: getUpdatedQuery(
this.$route.query,
itemNameParent,
e.target.value
)
});