.faq__answer
не растягивал родительский элемент и, соответственно, не перемещал лежащие ниже .faq__question
, надо задать ему position: absolute
. И ещё z-index
побольше, чем у .faq__quest
, чтобы не прятался за ними.visibility
- так, чтобы элемент, будучи скрытым, продолжал занимать отведённое ему место.tbody
- их в таблице может быть несколько. Нулевой элемент переданного массива отображается всегда, а остальные по условию. Как-то так:props: [ 'items' ],
data: () => ({
showAll: false,
}),
<tbody>
<tr>
<td>{{ items[0] }}</td>
<td>
<button
v-if="items.length > 1"
v-text="showAll ? '-' : '+'"
@click="showAll = !showAll"
></button>
</td>
</tr>
<template v-if="showAll">
<tr v-for="n in items.slice(1)">
<td>{{ n }}</td>
<td></td>
</tr>
</template>
</tbody>
<table>
<v-tbody v-for="n in items" :items="n" />
</table>
<template #thumb-label="{ value }">
{{ ticksLabels[value - min] }}
</template>
computed: {
items() {
return this.ticksLabels.map((n, i) => ({
text: n,
value: this.min + i,
}));
},
},
от <v-select :items="items" v-model="range[0]"></v-select>
до <v-select :items="items" v-model="range[1]"></v-select>
<div v-for="{ audio, index } in audios"
function diff(data1, data2, key = n => n) {
const getKey = key instanceof Function ? key : n => n[key];
const keys = new Set(Array.from(data2, getKey));
const result = [];
for (const n of data1) {
if (!keys.has(getKey(n))) {
result.push(n);
}
}
return result;
}
// ваш случай
const result = diff(arr1, arr2, 'id');
// есть и другие варианты использования
diff(Array(10).keys(), Array(7).keys()) // [ 7, 8, 9 ]
diff('ABCDE', 'ace', n => n.toLowerCase()) // [ 'B', 'D' ]
state.checkboxes.map(n => n.id === action.id
? { ...n, active: !n.active }
: n
)
function onChange() {
document.querySelector('селектор элемента для вывода результата проверки').innerText = [
// здесь массив селекторов вида
// input[имя_атрибута1="значение1"][имя_атрибута2="значение2"]:checked
].every(n => document.querySelector(n))
? 'какой-то текст'
: 'какой-то другой текст';
}
onChange();
document.addEventListener('change', e => {
if (e.target.matches('input[type="radio"]')) {
onChange();
}
});
const priceObj = Object.fromEntries(price.map((n, i) => [ `ad${i}`, n.ad ]));
const priceObj = price
.map(Object.entries)
.reduce((acc, [[ k, v ]], i) => (acc[k + i] = v, acc), {});
const priceObj = {};
for (const [ i, n ] of price.entries()) {
for (const k in n) {
priceObj[k.concat(i)] = n[k];
break;
}
}
Object.entries(str.split('').reduce((acc, n) => (acc[n] = (acc[n] ?? 0) + 1, acc), {}))
[...[...str].reduce((acc, n) => acc.set(n, -~acc.get(n)), new Map)]
Object.values(str).sort().join('').match(/(.)\1*/g)?.map(n => [ n[0], n.length ]) ?? []
Array.from(new Set(str), n => [ n, str.split(n).length - 1 ])
computed: {
newTodoValid() {
return this.newTodo.length >= 10;
},
},
<input :class="newTodoValid ? 'valid' : 'not-valid'">
<button :disabled="!newTodoValid">
.valid {
border: 2px solid green;
}
.not-valid {
border: 2px solid red;
}
const result = Object.values(runs.reduce(
(acc, n) => (acc[n.projectId]?.description.push(n), acc),
Object.fromEntries(projects.map(n => [ n.id, { ...n, description: [] } ]))
));
const result = projects.map(function(n) {
return {
...n,
description: this[n.id] ?? [],
};
}, runs.reduce((acc, n) => ((acc[n.projectId] = acc[n.projectId] ?? []).push(n), acc), {}));
const result = projects.map(n => ({
...n,
description: runs.filter(m => m.projectId === n.id),
}));