по клику на чекбокс не происходит фильтрация items
как запустить bootstrap пример
как можно реализовать фильтрацию списка по статусу...
...по клику на кнопки
const func = () => {
console.log('hello, world!!');
setTimeout(func, 500 + Math.random() * 1000 | 0);
};
func();
const insert = (str, indices, substr = ' ') =>
Array.prototype.reduce.call(
str,
(acc, n, i) => acc + (indices.includes(i) ? substr : '') + n,
''
);
// или
const insert = (str, indices, substr = ' ') => [...indices]
.sort((a, b) => b - a)
.reduce((acc, n) => (acc.splice(n, 0, substr), acc), [...str])
.join('');
// или
const insert = (str, indices, substr = ' ') => []
.concat(0, indices)
.sort((a, b) => a - b)
.map((n, i, a) => str.slice(n, a[i + 1]))
.join(substr);
// или
const insert = (str, indices, substr = ' ') => indices.length
? str.replace(RegExp(indices.map((n, i) => `(?<=^.{${n}})`).join('|'), 'g'), substr)
: str;
str = insert(str, [ 1, 3, 6, 8, 10 ]);
. $(window).on('scroll', function() {
const top = $(this).scrollTop();
const index = [ 50, 100, 150, Infinity ].findIndex(n => n > top);
$('.int > div').removeClass('active').eq(index).addClass('active');
}).scroll();
не могу понять, как сделать так, чтобы при втором условии числа выводились от меньшего к большему
const step = Math.sign(p2 - p1);
while (Math.abs(p2 - p1) >= 1) {
p1 += step;
console.log(p1);
}
[ p1, p2 ] = p1 > p2 ? [ p2, p1 ] : [ p1, p2 ];
while (p1 < p2) {
p1 += 1;
console.log(p1);
}
const
[ name, price, number ] =
[ 'name', 'price', 'number' ]
.map(n => document.querySelector(`input[name="${n}"]`).value.split(', '));
const arr = name.map((n, i) => ({
name: n,
price: price[i],
number: +number[i],
}));
v-slot:cell(index)="data"
slot="index" slot-scope="data"
numberInput.addEventListener('input', ({ target: t }) => {
t.value = ((t.value.match(/\d/g) || []).join('').match(/\d{1,4}/g) || []).join(' ');
});
const { position: { x, y }, cell_radius, food_size, food } = this;
const isIntersects = item =>
(item.x - x) ** 2 + (item.y - y) ** 2 <= (cell_radius + food_size) ** 2;
food.splice(0, food.length, ...food.filter(n => !isIntersects(n)));
// или
for (let i = food.length; i--;) {
if (isIntersects(food[i])) {
food.splice(i, 1);
}
}
// или
let countEaten = 0;
for (let i = 0; i < food.length; i++) {
food[i - countEaten] = food[i];
countEaten += isIntersects(food[i]);
}
food.length -= countEaten;
const index = str.search(/\d/);
.const index = str.match(/^(\D*\d)?/)[0].length - 1;
// или
const index = [...str].findIndex(n => !Number.isNaN(+n));
// или
let index = -1;
for (let i = 0; i < str.length; i++) {
if ('0123456789'.includes(str[i])) {
index = i;
break;
}
}
@submit.prevent
. Или клик по кнопке обрабатывайте иначе: @click.prevent="addGuest"
. const rows = useMemo(() => data.length
? data[0].arr.map((n, i) => data.map(m => m.arr[i]))
: []
, [ data ]);
<table>
<tbody>
{rows.map(n => <tr>{n.map(m => <td>{m}</td>)}</tr>)}
</tbody>
</table>
store.dispatch('config/loadMain').then(() => {
new Vue({
...