есть массив индексов[0, 3, 1, empty, 2]
<...>
должно быть -[100, 400, 200, empty, 300]
for (let i = 0; i < indexes.length; i++) {
if (indexes.hasOwnProperty(i)) {
arr.push(arr[indexes[i]]);
} else {
arr.length++;
}
}
arr.splice(0, arr.length - indexes.length);
arr.splice(0, arr.length, ...indexes.map(i => arr[i]));
ol
на transition-group
:<transition-group tag="ol" name="todo">
<li
v-for="(todo, i) in todos"
:key="todo.id"
@click="todos.splice(i, 1)"
>{{ todo.text }}</li>
</transition-group>
li {
transition: all 0.7s;
}
.todo-leave-active {
position: absolute;
}
.todo-leave-to {
transform: translateX(500px);
opacity: 0;
}
:class="{ 'authorization__label--done': name }"
:class="{ 'authorization__label--done': password }"
const className = 'carusel__item_active';
.const hasClass = el => el.classList.contains(className);
// или
const hasClass = el => el.matches(`.${className}`);
// или
const hasClass = el => el.className.split(' ').includes(className);
// или
const hasClass = el => RegExp(`(^| )${className}( |$)`).test(el.classList.value);
const activeSlide = Array.prototype.find.call(items, hasClass);
// или
let activeSlide = null;
for (const n of items) {
if (hasClass(n)) {
activeSlide = n;
break;
}
}
// или
const [ activeSlide ] = [...items].filter(hasClass);
// или
let activeSlide = null;
for (let i = 0; i < items.length && !activeSlide; i++) {
activeSlide = hasClass(items[i]) ? items[i] : activeSlide;
}
function onMarkerClick(e) {
map.setZoom(8);
map.panTo(e.latLng);
}
for (const f of features) {
const marker = new google.maps.Marker({
position: f.position,
icon: icons[f.type].icon,
map,
});
marker.addListener('click', onMarkerClick);
}
this.setState({
async componentDidMount() {
for (const url of urlList) {
const
dataAPI = [ ...this.state.dataAPI, await servicesAPI.getResourse(url) ],
loaded = dataAPI.length === urlList.length;
await new Promise(r => this.setState({ dataAPI, loaded }, r));
}
}
const input = document.querySelector('input');
const buttons = document.querySelectorAll('button');
buttons.forEach(n => n.addEventListener('click', onClick));
const classes = [
[ 'id1', 'class1' ],
[ 'id2', 'class2' ],
[ 'id3', 'class3' ],
];
function onClick() {
classes.forEach(n => input.classList.toggle(n[1], n[0] === this.id));
}
<button data-class="class1">click me</button>
<button data-class="class2">click me</button>
<button data-class="class3">click me</button>
function onClick() {
buttons.forEach(n => input.classList.toggle(n.dataset.class, n === this));
}
в product.vue делаю при клике <...> в product.vue все норм выводит, в shop.vue hover = null
const count = (max, timeout) => (function next(i) {
if (i <= max) {
setTimeout(() => {
console.log(i);
next(++i);
}, timeout(i));
}
})(0);
count(100, i => i * 5);
function debounce(f, delay) {
let timeoutId = null;
return function() {
clearTimeout(timeoutId);
timeoutId = setTimeout(() => f.apply(this, arguments), delay);
};
}
function throttle(f, delay) {
let lastCall = -Infinity;
return function() {
const now = +new Date;
if (now - lastCall > delay) {
lastCall = now;
return f.apply(this, arguments);
}
};
}
$count = array_reduce(array_keys($arr), function($acc, $n) {
return $acc + (strpos($n, 'my.key') === 0);
}, 0);
v-for
вешаем на template
, внутренний на tr
, ячейки с rowspan'ами выводятся только на нулевой итерации внутреннего цикла:<template v-for="row in rows">
<tr v-for="(n, i) in row.links">
<td v-if="!i" :rowspan="row.links.length">{{ row.name }}</td>
<td v-if="!i" :rowspan="row.links.length">{{ row.age }}</td>
<td>{{ n }}</td>
</tr>
</template>
template
и v-for
:<template v-if="!i">
<td v-for="k in [ 'name', 'age' ]" :rowspan="row.links.length">{{ row[k] }}</td>
</template>
<tr v-for="row in rows">
<td v-for="item in row">
<template v-if="item instanceof Array">
<div v-for="n in item">{{ n }}</div>
</template>
<template v-else>{{ item }}</template>
</td>
</tr>
<template v-for="row in rows">
<tr>
<td :rowspan="row.links.length">{{ row.name }}</td>
<td :rowspan="row.links.length">{{ row.age }}</td>
<td>{{ row.links[0] }}</td>
</tr>
<tr v-for="n in row.links.slice(1)">
<td>{{ n }}</td>
</tr>
</template>
.mdl-radio .mdl-radio__button:checked ~ .mdl-radio__outer-circle {
border-color: red;
}
.mdl-radio .mdl-radio__button:checked ~ .mdl-radio__inner-circle {
background-color: orange;
}
.mdl-radio .mdl-radio__button:checked ~ .mdl-radio__label {
color: blue;
}
v-for
по индексам нужных вам элементов:<tr v-for="item in parsedCSV">
<td v-for="i in [ 0, 3 ]">{{ item[i] }}</td>
</tr>
shortItems() {
return this.parsedCSV.map(([ name,,,job ]) => [ name, job ]);
},
<tr v-for="item in shortItems">
<td v-for="n in item">{{ n }}</td>
</tr>