Немного недопонял, можешь продемонстрировать как это задать?
data: () => ({
devices: [],
}),this.devices = Object.entries(res.data).map(([ id, n ]) => ({ ...n, id }));<ul>
<li v-for="d in devices" :key="d.id">
...
function getRootItem($id, $array) {
foreach ($array as $item) {
if ($item['id'] === $id) {
$parent = $item['parent'];
return $parent === 0 ? $item : getRootItem($parent, $array);
}
}
return null;
}
const getNextDay = (day, date = new Date()) =>
new Date(
date.getFullYear(),
date.getMonth(),
date.getDate() + ((7 + day - date.getDay()) % 7)
);
const nextSaturday = getNextDay(6);
получаю ошибку
вызываю в дочернем компоненте this.props.getCity(1, 'П')
getCity={this.getCity}, при этом метод getCity в родительском компоненте отсутствует. Есть getCities. Это как?передается пустой токен
{this.state.token && <NewAdvert id="newadvert"
user={this.state.fetchedUser}
cities={this.cities}
getCities={this.getCities}
getCity={this.getCity}
token={this.state.token}
getToken={this.getToken}
go={this.go}
/>}
Предполагается, что когда пользователь нажмет на фильтр, у меня вызовется функция setRouter...
.push(item) на .push(+item) (или .push(Number(item)), или .push(parseInt(item))). Соответственно, надо сделать числом и search - для этого достаточно добавить соответствующий модификатор v-model..sort() на .sort((a, b) => a - b).computed: {
array() {
return this.info
.split(';')
.map(n => parseInt(n))
.filter(n => !Number.isNaN(n))
.sort((a, b) => a - b);
},
},
const values = Object.values(arr.reduce((acc, n) => {
const t = acc[n.from];
acc[n.from] = (t && t.to > n.to) ? t : n;
return acc;
}, {})).map(n => n.val);const values = Object.values(arr.reduce((acc, n) => {
(acc[n.from] = acc[n.from] || [])[n.to] = n.val;
return acc;
}, {})).map(n => n.pop());const values = [...arr]
.sort((a, b) => (a.from - b.from) || (a.to - b.to))
.filter((n, i, a) => !a[i + 1] || a[i + 1].from !== n.from)
.map(n => n.val);Можно с помощью lodash.
const values = _
.chain(arr)
.groupBy('from')
.map(n => _.maxBy(n, m => m.to).val)
.value();
$(document).on('input', '.price-item', function() {
const min = +$('.min-price').val() || 0;
const max = +$('.max-price').val() || Infinity;
$('.filter')
.hide()
.filter(function() {
const val = parseFloat($('.price', this).text());
return min <= val && val <= max;
})
.show();
});
$('div.award a').each((i, n) => n.onmouseover = n.onmouseout = null);$('div.award a').removeAttr('onmouseover onmouseout');$('div.award a').prop({
onmouseover: null,
onmouseout: null,
});
$('table td:nth-child(1)').html((i, html) => {
return '<a href="?name=' + html + '">' + html + '</a>';
});document.querySelectorAll('tbody tr').forEach(n => {
const td = n.children[0];
const text = td.textContent;
td.innerHTML = `<a href="?name=${text}">${text}</a>`;
});for (const { cells: [ td ] } of document.querySelector('tbody').rows) {
const a = document.createElement('a');
a.href = '?name='.concat(td.innerText);
a.append(...td.childNodes);
td.append(a);
}