isBarMenuClicked: false, // эту переменную нужно передать
$emit('click')
, подписывайтесь на событие в родительском компоненте, переключайте там значение переменной, отвечающей за открытость меню и передавайте её в меню как параметр. return
?const events = [];
collectEvents:
for(let z = 0; z < arrOfEvents.length; z++){
return memo
заменяете наevents.push(memo);
continue collectEvents;
return events;
. .one path {
fill: #909090;
}
.one.active path {
fill: #f00;
}
const itemSelector = '.one';
const activeClass = 'active';
document.addEventListener('click', function(e) {
const el = e.target.closest(itemSelector);
if (el) {
el.classList.toggle(activeClass);
}
});
// или
document.querySelectorAll(itemSelector).forEach(function(n) {
n.addEventListener('click', this);
}, e => e.currentTarget.classList.toggle(activeClass));
state: {
date: null,
interval: null,
},
mutations: {
update(state) {
state.date = new Date();
},
start(state) {
if (!state.interval) {
state.interval = setInterval(this.commit, 1000, 'update');
}
},
stop(state) {
if (state.interval) {
clearInterval(state.interval);
state.interval = null;
}
},
},
computed: {
timerActive() {
return !!this.$store.state.interval;
},
timeStr() {
const { date } = this.$store.state;
return date instanceof Date
? [ 'getHours', 'getMinutes', 'getSeconds' ]
.map(n => `${date[n]()}`.padStart(2, 0))
.join(':')
: 'ВРЕМЕНИ НЕТ';
},
},
created() {
this.$store.commit('start');
},
<button @click="$store.commit('start')" :disabled="timerActive">start</button>
<button @click="$store.commit('stop')" :disabled="!timerActive">stop</button>
<div>{{ timeStr }}</div>
v-on="условие ? { событие: обработчик } : {}"
v-on="{ событие: условие ? обработчик : null }"
const result = arrs.reduce(
(acc, arr) => (arr.forEach((n, i) => acc[i].push(...n.slice(acc[i].length))), acc),
Array.from({ length: Math.max(...arrs.map(arr => arr.length)) }, () => [])
);
const result = arrs.reduce((acc, arr) => (
arr.forEach((n, i) => (
acc[i] = acc[i] || [],
n.forEach((m, j) => acc[i][j] = acc[i][j] || m)
)),
acc
), []);
хочу, чтобы модальное окно отображалось столько раз, сколько событий в дне, и каждый раз с подробной информацией о новом событии
computed: {
detailInformationOfEvent() {
return this.detailInformationOfEvents[0];
},
...
this.detailInformationOfEvents.push({
...
});
v-show="detailInformationOfEvent"
detailInformationOfEvents.shift()
Метод Performance.now()
возращает временную метку DOMHighResTimeStamp, измеряемую в миллисекундах
const createArr = (len, digit, count) => {
const d = [...Array(9)].map((n, i) => i + (i >= digit));
return [...Array(len)].map(() => {
const number = [...Array(Math.random() * 10 | 0)].map(() => d[Math.random() * d.length | 0]);
for (let i = 0; i < count; i++) {
number.splice(Math.random() * number.length | 0, 0, digit);
}
return +number.join('');
});
};
const arr = createArr(5, 1, 2);
const tbody = document.querySelector('#test tbody');
const keys = [ 'name.firstName', 'name.lastName', 'about', 'eyeColor' ].map(n => n.split('.'));
const getVal = (obj, keys) => keys.reduce((p, c) => p != null ? p[c] : p, obj);
for (const n of data) {
keys.forEach(function(k) {
this.insertCell().textContent = getVal(n, k);
}, tbody.insertRow());
}
// или
tbody.insertAdjacentHTML('beforeend', data
.map(n => `
<tr>${keys.map(k => `
<td>${getVal(n, k)}</td>`).join('')}
</tr>`)
.join('')
);
AutoNumeric.multiple('.numeric', {
decimalCharacter : '.',
digitGroupSeparator : ' ',
})
<div id="images">
<img src="https://placehold.co/200x200/FF0000/FFFFFF/png">
<img src="https://placehold.co/200x200/00FF00/000000/png">
<img src="https://placehold.co/200x200/0000FF/FFFFFF/png">
</div>
#images img {
transition: transform 0.7s;
}
.rotate {
transform: rotateY(180deg);
}
const toggleRotate = el => el.classList.toggle('rotate');
document.querySelectorAll('#images img').forEach((n, i) => {
setTimeout(setInterval, 300 * i, toggleRotate, 2000, n);
});
#images img {
animation: rotate 4s infinite;
}
#images img:nth-child(1) { animation-delay: 0s; }
#images img:nth-child(2) { animation-delay: 0.3s; }
#images img:nth-child(3) { animation-delay: 0.6s; }
@keyframes rotate {
0%, 75%, 100% {
transform: rotateY(0deg);
}
25%, 50% {
transform: rotateY(180deg);
}
}