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, cell_radius, food_size, food } = this;
const isIntersects = (a, b) =>
(a.x - b.x) ** 2 + (a.y - b.y) ** 2 <= (cell_radius + food_size) ** 2;
food.reduceRight((_, n, i, a) => isIntersects(n, position) && a.splice(i, 1), null);
// или
food.splice(0, food.length, ...food.filter(n => !isIntersects(n, position)));
// или
food.length -= food.reduce((acc, n, i, a) => (
a[i - acc] = n,
acc + isIntersects(n, position)
), 0);
const index = str.search(/\d/);
.const index = str.match(/^(\D*\d)?/)[0].length - 1;
// или
const index = [...str].findIndex(n => !Number.isNaN(Number(n)));
// или
let index = -1;
for (let i = 0; i < str.length; i++) {
if ('0123456789'.includes(str.charAt(i))) {
index = i;
break;
}
}
// или
const index = (function get(i, n = str[i]) {
return (
!n ? -1 :
+n === +n ? i :
get(-~i)
);
})(0);
@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({
...
При движении вверх или влево координаты искажаются.
$('селектор картинок').unwrap();
function unwrap(element) {
const wrapper = element.parentNode;
const fragment = new DocumentFragment();
DocumentFragment.prototype.append.apply(fragment, wrapper.childNodes);
wrapper.parentNode.replaceChild(fragment, wrapper);
}
// или
const unwrap = ({ parentNode: wrapper }) =>
wrapper.replaceWith(...wrapper.childNodes);
document.querySelectorAll('селектор картинок').forEach(unwrap);
const newArr = arr.map((n, i) => n.repeat(i + 1));
const newArr = arr.map((n, i) => Array(i + 1).fill(n).join(''));
const newArr = arr.map((n, i) => Array(i + 2).join(n));
const newArr = [];
for (let i = 0; i < arr.length; i++) {
let str = '';
for (let j = 0; j <= i; j++) {
str += arr[i];
}
newArr.push(str);
}
const newArr = [];
for (const n of arr) {
let str = '';
while ((str = str.concat(n)).length <= newArr.length) ;
newArr[newArr.length] = str;
}