почему-то не отрабатывает ни один из хуков
const rootComments = Object
.entries(comments)
.reduce((acc, [ k, v ]) => v.parent === null ? { ...acc, [k]: v } : acc, {});
// или
const rootComments = {};
for (const k of Object.keys(comments)) {
if (comments[k].parent === null) {
rootComments[k] = comments[k];
}
}function createTree({
data,
key = 'id',
parentKey = 'parentId',
childrenKey = 'children',
}) {
const tree = data.reduce((acc, n) => (
acc[n[key]] = { ...n, [childrenKey]: {} },
acc
), {});
return Object.values(tree).reduce((acc, n) => {
const p = tree[n[parentKey]];
(p ? p[childrenKey] : acc)[n[key]] = n;
return acc;
}, {});
}const commentsTree = createTree({
data: Object.values(comments),
parentKey: 'parent',
});
<button class="click-count">click me</button>
<button class="click-count">click me</button>
<button class="click-count">click me</button>document.addEventListener('click', ({ target: t }) => {
if (t.classList.contains('click-count')) {
t.innerText = (t.innerText | 0) + 1;
}
});
// или
const onClick = e => e.target.textContent = -~e.target.textContent;
document.querySelectorAll('.click-count').forEach(n => n.addEventListener('click', onClick));
.imageContainer:empty {
height: 0;
border: none;
}.imageContainer:empty {
visibility: hidden;
/* или */
opacity: 0;
}box-sizing: border-box; для .imageContainer.flex: 0 0 30%; у .imageContainer, а у их родителя пусть будет так:display: grid;
grid-template-columns: repeat(3, 30%);
justify-content: space-between;
<section id="app-pro"> <router-view></router-view> </section>
new Vue({ el: '#app-pro', render: h => h(AppPro), router }).$mount('#app-pro')
Therenderfunction has priority over the render function compiled fromtemplateoption or in-DOM HTML template of the mounting element which is specified by theeloption.