!==
) и закрыт, т.е., открываете все, кроме закрываемого.document.addEventListener('click', e => {
const t = e.target;
const heading = t.closest('.panel-heading');
const nextStep = t.closest('.construct-btn');
const collapse =
heading ? heading.nextElementSibling :
nextStep ? t.closest('.panel').nextElementSibling.querySelector('.panel-collapse') :
null;
if (collapse) {
e.preventDefault();
t.closest('.panel-group').querySelectorAll('.panel-collapse').forEach(n => {
n.classList[n === collapse ? 'toggle' : 'remove']('in');
});
}
});
Где задается этот параметр?
computed: mapState({
products: state => state.product.all.map(n => ({
...n,
isOrdered: state.order.all.some(m => m.id === n.id),
})),
}),
<b-button :disabled="product.isOrdered"
.<div v-if="product.isOrdered"
.computed: {
isOrdered() {
return Object.fromEntries(this.$store.state.order.all.map(n => [ n.id, true ]));
},
},
product.isOrdered
из предыдущего варианта, будет isOrdered[product.id]
.Где ошибки?
.active
недостаточно специфичен. А ещё лучше - надо было сразу скопипастить оригинал как есть, а не пытаться вносить изменения, которых не понимаете.Но выражения в моем понимании это...
function addClickListeners(buttonsSelector, dialogSelector) {
const buttons = document.querySelectorAll(buttonsSelector);
const dialog = document.querySelector(dialogSelector);
buttons.forEach(n => n.addEventListener('click', e => {
e.preventDefault();
dialog.style.display = 'block';
}));
dialog.addEventListener('click', ({ target }) => {
if (target.classList.contains('popup-close')) {
document.getElementById('name_1').disabled = true;
document.getElementById('phone_1').disabled = true;
dialog.style.display = 'none';
} else if (!target.closest('.popup-content')) {
dialog.style.display = 'none';
}
});
}
addClickListeners('header .contacts a', '.popup-call');
addClickListeners('.sentence-btn', '.popup-discount');
addClickListeners('.check-btn', '.popup-check');
document.addEventListener('click', function(e) {
const heading = e.target.closest('.panel-heading');
if (heading) {
e.preventDefault();
heading.closest('.panel-group').querySelectorAll('.panel-collapse').forEach(n => {
n.classList[n === heading.nextElementSibling ? 'toggle' : 'remove']('in');
});
}
});
по какой-то причине срабатывает только первый console.log()
function diff(data1, data2, key = n => n) {
const getKey = key instanceof Function ? key : n => n[key];
const keys = new Set(Array.from(data2, getKey));
return Array.prototype.filter.call(data1, n => !keys.has(getKey(n)));
}
// ваш случай
diff(array1, array2, 'name')
// есть и другие варианты применения
diff([ 1, 2, 3, 4, 5 ], [ 1, 2, 3 ]) // [4, 5]
diff('abcde', 'ACE', n => n.toLowerCase()) // ['b', 'd']
v-model
.props: {
value: Number,
...
computed: {
item() {
return this.items[this.value];
},
...
<transition name="slide-fade" mode="out-in">
<div class="content" :key="value">
<h2>{{ item.title }}</h2>
<p>{{ item.text }}</p>
</div>
</transition>
methods: {
next(change) {
const len = this.items.length;
this.$emit('input', (this.value + change + len) % len);
},
...
<button @click="next(-1)">Prev</button>
<button @click="next(+1)">Next</button>
data: () => ({
active: 1,
...
<v-slider
v-model="active"
...
$('.all-blocks.color-blocks .block').attr('id', function(i, id) {
return $(this).hasClass(id) ? `${id}_2` : id;
});
document.querySelectorAll('.all-blocks.color-blocks .block').forEach(n => {
n.id += n.classList.contains(n.id) ? '_2' : '';
});
<option value="[55.751244,37.618423]">Москва</option>
select.addEventListener('change', function() {
map.setCenter(JSON.parse(this.value));
});