const $headers = $('.bf-attr-group-header');
$headers.each(i => $headers
.eq(i)
.nextUntil($headers.get(i + 1))
.wrapAll('<div class="wrapper">')
);
document.querySelectorAll('.bf-attr-group-header').forEach((n, i, a) => {
const wrapper = document.createElement('div');
const elems = [];
for (let el = n; (el = el.nextElementSibling) && el !== a[i + 1]; elems.push(el)) ;
wrapper.append(...elems);
wrapper.classList.add('wrapper');
n.after(wrapper);
});
document.querySelectorAll('button').forEach(n => n.addEventListener('click', onClick));
function onClick() {
const count = (+this.dataset.clickCount || 0) + 1;
this.innerText = `clicked: ${count}`;
this.dataset.clickCount = count;
}
$('span').text((i, text) => text[0] === '-' ? text : `+${text}`);
document.querySelectorAll('span').forEach(n => {
n.innerText = n.innerText.replace(/^(?!-)/, '+');
});
for (const n of document.getElementsByTagName('span')) {
n.textContent = '+'.slice(n.textContent[0] === '-') + n.textContent;
}
function getUrls($parts, $acc = '') {
$urls = [];
if (count($parts)) {
$part = array_shift($parts);
if (!is_array($part)) {
$part = [ $part ];
}
foreach ($part as $p) {
array_push($urls, ...getUrls($parts, ($acc ? $acc.'/' : '').$p));
}
} else {
$urls[] = $acc;
}
return $urls;
}
$urls = getUrls($urlFragments);
data: () => ({
mainCategories: [
{ merchantId: '1', checked: true },
{ merchantId: '2', checked: true },
...
],
}),
computed: {
checkedCategories() {
return this.mainCategories.filter(n => n.checked).map(n => n.merchantId);
},
},
<li v-for="n in mainCategories">
<label>
<input type="checkbox" v-model="n.checked">
{{ n.merchantId }}
</label>
</li>
created() {
this.checkedCategories = this.mainCategories.map(n => n.merchantId);
},
data: () => ({
items: [
{ name: 'PHOTOSHOP', val: 88, color: 'red' },
{ name: 'ILLUSTRATOR', val: 92, color: 'green' },
{ name: 'SKETCH', val: 90, color: 'orange' },
{ name: 'AFFTER EFFECTS', val: 98, color: 'blue' },
],
}),
border-bottom
например) у элемента списка:methods: {
liText: item => `${item.name} ${item.val}%`,
liStyle: item => ({
'border-bottom': `3px solid ${item.color}`,
width: `${item.val}%`,
}),
},
<ul>
<li
v-for="n in items"
v-text="liText(n)"
:style="liStyle(n)"
></li>
</ul>
[...new Set(arr)]
.Object.values(arr.reduce((acc, n) => (acc[n] = n, acc), {}))
// или
Array.from(new Map(arr.map(n => [ n, n ])).values())
// или
arr.filter(function(n) {
return !(this[n] = this.hasOwnProperty(n));
}, {})
// или
arr.filter(((picked, n) => !picked.set(n, picked.has(n)).get(n)).bind(null, new Map))
// или
arr.filter((n, i, a) => i === a.indexOf(n))
// или
arr.reduce((acc, n) => (acc.includes(n) || acc.push(n), acc), [])
data: () => ({
show: false,
items: [ 'в сети', 'занят', 'отсутствую', 'в самолете', 'в пути' ],
status: 'статус',
}),
methods: {
selectStatus(status) {
this.status = status;
this.show = false;
},
},
<div
v-text="status"
@click="show = !show"
></div>
<ul v-show="show">
<li
v-for="n in items"
v-text="n"
@click="selectStatus(n)"
></li>
</ul>
{ имя_диалога: состояние }
. Тогда при обновлении состояния диалогов не будет необходимости обращаться к ним поимённо:mutations: {
dialogShow: (state, payload) => Object.assign(state.modals, payload),
},
modals() {
return new Proxy(this.$store.state.modals, {
set: (target, prop, value) => {
this.$store.commit('dialogShow', { [prop]: value });
return true;
},
});
},
<el-button @click="modals.dialogSignIn = true">sign in</el-button>
<el-dialog :visible="modals.dialogSignIn" @close="modals.dialogSignIn = false">
<span slot="footer" class="dialog-footer">
<el-button @click="modals.dialogSignIn = false">Закрыть</el-button>
</span>
</el-dialog>
То есть если пользователь кликнул три раза по первой кнопке, то дочерний компонент значение "4" вывел только один раз.
В Network указывается не jpeg, а text/html
mounted() {
const img = new Image();
img.onload = () => this.$refs.canvas.getContext('2d').drawImage(img, 0, 0);
img.src = '...';
},