<script setup>
const foo = ref('foo')
const bar = () => console.log('bar')
defineExpose({
foo,
bar,
})
</script>
<template>
<Child ref="child" />
</template>
<script setup>
const child = ref(null);
onMounted(() => {
console.log(child.value.foo)
console.log(child.value.bar())
})
</script>
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="{IMAGE URL}" />
shell_exec
+ chromium
с флагами headless
disable-gpu
и print-to-pdf
отрисует вам что угодно, что может отобразить chrome.var globalVar = "Hello!";
Object.defineProperty(window, 'test', {
get() { return globalVar } // ну и другие необходимые дескрипторы, опущены для примера.
});
console.log(test); // "Hello!"
globalVar = "world!";
console.log(test); // "world!"
// имена свойств можно передавать в виде массива
const pick = (obj, keys) => Object.fromEntries(keys.map(n => [ n, obj[n] ]));
const newObj = pick(obj, [ 'b', 'c' ]);
// или как отдельные значения
const pick = (obj, ...keys) => keys.reduce((acc, n) => (acc[n] = obj[n], acc), {});
const newObj = pick(obj, 'b', 'c');
const pickExisting = (obj, keys) =>
Object.fromEntries(keys.filter(n => n in obj).map(n => [ n, obj[n] ]));
const pickOwn = (obj, keys) =>
keys.reduce((acc, n) => (Object.hasOwn(obj, n) && (acc[n] = obj[n]), acc), {});
const pick = (obj, filterFn) => Object.fromEntries(Object.entries(obj).filter(filterFn));
const obj1 = pick(obj, ([ key, val ]) => 'abc'.includes(key) && val % 2); // {a: 1, c: 3}
const obj2 = pick(obj, n => n[1] > 2); // {c: 3, d: 5}
let statuses = document.querySelectorAll('.M')
statuses.forEach((item) => {
if (item.innerText === 'Активен') {
item.classList.add('Free')
}
if (item.innerText === 'Заблокирован') {
item.classList.add('Blocked')
}
}
)
<MyStatus
class="M"
:class="{'Free': item.Status==='Активен', 'Blocked': item.Status==='Заблокирован'}"
style="width: 75%; padding: 0.25em 0.75em"
>
{{ player.Status }}
</MyStatus>
const slider = $(".slider").slick({
centerMode: true,
slidesToShow: 4
});
const breakpoint = window.matchMedia("(max-width: 992px)");
const breakpointChecker = () => {
if (breakpoint.matches) {
slider.slick('init');
} else {
slider.slick('destroy');
}
};
breakpoint.addEventListener("change", breakpointChecker);
breakpointChecker();