<transition-group name='slide-components' mode="out-in"
transition-group принимаетте же атрибуты, что и у<transition>кромеmode
transition-group тут следует использовать transition:<transition name="slide-components" mode="out-in">
<p :key="window">{{ window }}</p>
</transition>
<el-select v-model="this.divisions"<el-option v-for="(dvs, key) in divisions"el-option не зарегистрирован.
1 + Math.max(0, ...articles.map(n => n.id))const getId = (() => {
let id = 0;
return () => ++id;
})();
overlay.click(e => {
if (e.target === e.delegateTarget) {
overlay.fadeOut();
}
});
// или
overlay.click(function(e) {
$(this).filter(e.target).fadeOut();
});overlay
.click(() => overlay.fadeOut())
.children()
.click(e => e.stopPropagation());
$.each($.parseJSON(response), (k, v) => $(`.${k}`).text(v));for (const [ k, v ] of Object.entries(JSON.parse(response))) {
document.querySelector(`.${k}`).innerText = v;
}
const first = document.querySelector('.listing');
const tag = 'p';
const arr = [...'ABCDEF'];first.after(...arr.map(n => {
const el = document.createElement(tag);
el.textContent = n;
return el;
}));
// или
first.replaceWith(first, ...arr.reduce((acc, n, i) => (
(acc[i] = document.createElement(tag)).innerText = n,
acc
), []));
// или
arr.reduce((prev, n) => (
prev.insertAdjacentElement('afterend', document.createElement(tag)),
prev.nextSibling.append(n),
prev.nextSibling
), first);
// или
const parent = first.parentNode;
const nodes = parent.childNodes;
arr.forEach(function(n) {
const el = document.createElement(tag);
el.appendChild(new Text(n));
parent.insertBefore(el, nodes[++this[0]]);
}, [ Array.prototype.indexOf.call(nodes, first) ]);
// или
first.insertAdjacentHTML(
'afterend',
arr.map(n => `<${tag}>${n}</${tag}>`).join('')
);
Конструкция this.items = JSON.parse(cart.response); - не работает, поскольку ajax функция в методе getUpdate – имеет свой контекст
Достучаться до app.items – тоже не получается.
onResize = () => {
this.setState(() => ({
/* ... */
}));
}
componentDidMount() {
window.addEventListener('resize', this.onResize);
this.onResize();
}
componentWillUnmount() {
window.removeEventListener('resize', this.onResize);
}
$('table').on('change', 'select', ({ target: t }) => {
$(t).replaceWith(t.value);
// или
$(t).prop('outerText', t.value);
// или
$(t).after(t.value).remove();
});const isSelect = el => el.tagName === 'SELECT';
// или
const isSelect = el => el.nodeName === 'SELECT';
// или
const isSelect = el => el.matches('select');
// или
const isSelect = el => el instanceof HTMLSelectElement;document.querySelector('table').addEventListener('change', ({ target: t }) => {
if (isSelect(t)) {
t.replaceWith(t.value);
// или
t.parentNode.replaceChild(new Text(t.value), t);
// или
t.outerText = t.value;
// или
t.after(t.value);
t.remove();
// или
t.parentNode.replaceChildren(...Array.from(
t.parentNode.childNodes,
n => n === t ? t.value : n
));
}
});
progress.css('background-color', [
{ min: 100, color: '#47C965' },
{ min: 40, color: '#f5dd30' },
{ min: 0, color: '#bf4542' },
].find(n => n.min <= strength).color);const tests = [ здесь перечисляете регулярные выражения ].map((n, i) => ({
regex: n,
message: error_wrap.attr(`data-error_${i + 1}`),
}));
const newArr = arr.map(function(n) {
return this[n];
}, arr.reduce((acc, n) => (acc[n] = acc.hasOwnProperty(n), acc), {}));
// или
const count = arr.reduce((acc, n) => (acc[n] = (acc[n] ?? 0) + 1, acc), {});
const newArr = arr.map(n => count[n] > 1);
// или
const newArr = arr.map((n, i, a) => a.indexOf(n) !== a.lastIndexOf(n));arr.forEach(function(n, i, a) {
a[i] = !!~-this.get(n);
}, arr.reduce((acc, n) => acc.set(n, -~acc.get(n)), new Map));
// или
const duplicates = arr.reduce((acc, n) => acc.set(n, acc.has(n)), new Map);
arr.splice(0, arr.length, ...arr.map(n => duplicates.get(n)));
// или
Object
.values(arr.reduce((acc, n, i) => ((acc[n] ??= []).push(i), acc), {}))
.forEach(n => n.forEach(i => arr[i] = n.length > 1));
$('select').change(function() {
const text = $(':checked', this).text();
console.log(text);
});document.querySelector('select').addEventListener('change', function(e) {
const select = this;
// или
// const select = e.target;
// const select = e.currentTarget;
const [ option ] = select.selectedOptions;
// или
// const option = select[select.selectedIndex];
// const option = select.querySelector(':checked');
// const option = [...select.options].find(n => n.selected);
const text = option.text;
// или
// const text = option.textContent;
// const text = option.innerText;
console.log(text);
});
document.querySelector('#filter-input').addEventListener('input', e => {
const val = e.target.value.toLowerCase();
container.querySelectorAll('.title').forEach(n => {
n.closest('.card').style.display = n.innerText.toLowerCase().includes(val)
? 'block'
: 'none';
});
});document.getElementById('filter-input').oninput = function() {
const val = this.value.toLowerCase();
for (const n of container.getElementsByClassName('title')) {
let card = n;
while (!(card = card.parentNode).classList.contains('card')) ;
card.hidden = n.textContent.toLowerCase().indexOf(val) === -1;
}
};
rangeValues: { ...this.$store.state.CarSetup },Object.entries(newValue).forEach(([ k, v ]) => {
if (v !== oldValue[k]) {
this.$store.commit('setCarInfo', { to: k, value: v });
}
});computed: {
rangeValues() {
return new Proxy(this.$store.state.carSetup, {
set: (target, key, val) => {
this.$store.commit('setCarInfo', { [key]: val });
return true;
},
});
},
},setCarInfo: (state, payload) => Object.assign(state.carSetup, payload),
const key = 'answer';.const obj = Object.fromEntries(arr.map((n, i) => [ `${key}${i + 1}`, n ]));const obj = arr.reduce((acc, n, i) => (acc[key + ++i] = n, acc), {});const obj = {};
for (const [ i, n ] of arr.entries()) {
obj[key.concat(-~i)] = n;
}const obj = (function get(arr) {
const i = arr.length;
const n = arr.pop();
return i
? { ...get(arr), [[ key, i ].join``]: n }
: {};
})([...arr]);
computed: {
filteredProducts() {
const keyword = this.keyword.toLowerCase();
return this.products.filter(item => (
(item.name.toLowerCase().includes(keyword)) &&
(!this.colors.length || this.colors.includes(item.color)) &&
(!this.sizes.length || this.sizes.some(n => item.size.includes(n))) &&
(!this.categories.length || this.categories.includes(item.category))
));
},
...computed: {
colorFilter() {
return Array
.from(new Set(this.products.map(n => n.color)))
.sort((a, b) => a.localeCompare(b));
},
...
onChange = {(event, userItem)=>handleChange(event, userItem)}
onChange={e => handleChange(e, userItem)}.onChange={handleChange.bind(userItem)},function handleChange(e) {
console.log('userItem', this);
console.log('value', e.target.value);
}
str[0] === str[0].toUpperCase()/^[A-Z]/.test(str)(c => 64 < c && c < 91)(str.charCodeAt(0))'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.includes(str.at(0))