<div class="icon"></div>.icon {
font-size: 60px;
display: inline-block;
border: 0.1em solid black;
border-radius: 0.5em;
width: 1em;
height: 2em;
position: relative;
}
.icon::before {
content: "";
display: inline-block;
position: absolute;
width: 0.2em;
height: 0.2em;
background: black;
left: 50%;
top: 30%;
transform: translateX(-50%);
box-shadow: 0 -0.4em black, 0 0.4em black;
}
.icon::after {
content: "";
display: inline-block;
border: 0.15em solid black;
border-left: 0;
border-top: 0;
width: 0.4em;
height: 0.4em;
position: absolute;
top: 60%;
left: 50%;
transform: translateX(-50%) rotate(45deg);
}
function codeAddress(address, geocoder, map) {
geocoder.geocode({ address }, function(results, status) {
if (status === 'OK') {
new google.maps.Marker({
map: map,
position: results[0].geometry.location,
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}address.forEach(n => codeAddress(n, geocoder, map));
как установить страницу пагинации (к примеру 2-ую или 3-ю)
data: () => ({
page: 1,
...
}),<v-data-table
:page.sync="page"
...как установить обработчик на клик по стрелке вперед
watch: {
page(val) {
...
},
},
const elements = document.querySelectorAll('li > ul');
const tag = 'span';
const text = 'hello, world!!';elements.forEach(n => {
n.before(document.createElement(tag));
n.previousSibling.textContent = text;
});for (const n of elements) {
const el = document.createElement(tag);
el.innerText = text;
n.parentNode.insertBefore(el, n);
}for (let i = 0; i < elements.length; i++) {
elements[i].insertAdjacentHTML('beforebegin', `<${tag}>${text}</${tag}>`);
}(function insert(i, n = elements.item(i)) {
if (n) {
const el = document.createElement(tag);
el.appendChild(new Text(text));
n.insertAdjacentElement('beforebegin', el);
insert(-~i);
}
})(0);
const selector = '.list-item';
const key1 = 'pagereview';
const key2 = 'pageslug';
const attr1 = `data-${key1}`;
const attr2 = `data-${key2}`;const $elements = $(selector);
// или
const elements = document.querySelectorAll(selector);$elements.show().filter((i, n) => $(n).data(key1) !== $(n).data(key2)).hide();
// или
$elements.each(function() {
const $this = $(this);
$this.toggle($this.attr(attr1) === $this.attr(attr2));
});
// или
elements.forEach(n => {
n.hidden = n.getAttribute(attr1) !== n.getAttribute(attr2);
});
// или
for (const { style, dataset } of elements) {
style.display = dataset[key1] === dataset[key2] ? 'block' : 'none';
}
// или (в стили надо будет добавить .hidden { display: none; })
for (let i = 0; i < elements.length; i++) {
const { classList: c, attributes: a } = elements[i];
c.toggle('hidden', a[attr1].value !== a[attr2].value);
}
:options="{ scrollWheelZoom: false }"
@update:zoom="zoom = $event"
@wheel.native="onWheel"methods: {
onWheel(e) {
if (e.deltaY < 0) {
this.zoom++;
e.preventDefault();
}
},
},
options: [
{
...
propToBeMultipliedByPrice: 'area',
},
{
...
propToBeMultipliedByPrice: 'perimeter',
},
],{{ option.price * calc[option.propToBeMultipliedByPrice] }}
преобразовать
['a' => [11, 12], 'b' => [21, 22]]
в
[['a' => 11, 'b' => 12], ['a' =>21, 'b' => 22]]
12 из a становится значением свойства b, а 21 - наоборот? Опечатка? - наверное, в a исходного массива лежат значения свойств a результата, аналогично и с b.array_map(fn($i) => array_combine(array_keys($arr), array_column($arr, $i)), array_keys(array_values($arr)[0]))
{{ dish[`title_${lang}`] }}v-text="dish['title_' + lang]":text.prop="dish['title_'.concat(lang)]"
const widgetsTransform = Object
.values(widgets.reduce((acc, n) => ((acc[n.type] = acc[n.type] ?? []).push(n), acc), {}))
.map(n => n.length > 1 ? ({ type: `Section${n[0].type}`, children: n }) : n[0]);const widgetsTransform = widgets
.reduce((acc, n, i, a) => (
(i && n.type === a[~-i].type) || acc.push([]),
acc[~-acc.length].push(n),
acc
), [])
.map(n => ~-n.length ? ({ type: 'Section' + n[0].type, children: n }) : n[0]);
не корректно работает
data: () => ({
scroll: 0,
}),
computed: {
buttonClass() {
return что-то, зависящее от значения this.scroll;
},
},
created() {
const { body } = document;
const onScroll = () => this.scroll = body.scrollTop;
body.addEventListener('scroll', onScroll);
this.$on('hook:beforeDestroy', () => body.removeEventListener('scroll', onScroll));
},<button :class="buttonClass"></button>
$('.price_min_max_btn').click(function() {
const min = +$('.price_min').val() || 0;
const max = +$('.price_max').val() || Infinity;
$('.item_block_filter')
.hide()
.filter(function() {
const price = +this.dataset.price;
return min <= price && price <= max;
})
.show();
});
<div v-for="(story, idx) in stories" :key="idx"><div v-for="n in stories.hits" :key="n.objectID">
.then(this.dates.push(response['dates'] ) ),.then(response => this.dates = response.data.dates)
// или
.then(response => this.dates.push(...response.data.dates))