computed: {
range() {
const prices = this.filterData.map(n => n.price);
return {
min: Math.min(...prices),
max: Math.max(...prices),
};
},
// или
range() {
return this.filterData.reduce(({ min, max }, { price: n }) => ({
min: min < n ? min : n,
max: max > n ? max : n,
}), { min: Infinity, max: -Infinity });
},
// или
range() {
const prices = this.filterData.map(n => n.price).sort((a, b) => a - b);
return {
min: prices[0] ?? Infinity,
max: prices[prices.length - 1] ?? -Infinity,
};
},
},
<input type="range" v-bind="range">