<keep-alive include="имя-компонента-страницы-с-табами">
<router-view></router-view>
</keep-alive>
$pattern = '/Сумма задания: (\d+\.\d+)/';
usort($arr, function($a, $b) use($pattern) {
preg_match($pattern, $a, $ma);
preg_match($pattern, $b, $mb);
return $mb[1] - $ma[1];
});
const citiesListNames = citiesList.map( item => { return item.name } )
приложение зависает от такого колличества данных
focusOnSelect: true
.$slick.on('click', '.slick-slide', function() {
$slick.slick('slickGoTo', this.dataset.slickIndex);
});
nums1 = nums1.slice(0, m).concat(nums2).sort((a, b) => a - b);
nums1.splice(0, nums1.length, ...[ ...nums1.slice(0, m), ...nums2 ].sort((a, b) => a - b));
// или
nums1.slice(0, m).concat(nums2).sort((a, b) => a - b).forEach((n, i) => nums1[i] = n);
<a :href="category.link">
router-link
, или уберите ссылки.v-if
) содержимое этого объекта.props: [ 'start', 'end', 'title', 'delay' ],
data: () => ({
val: null,
}),
created() {
this.val = this.start;
const interval = setInterval(() => {
if (++this.val >= this.end) {
clearInterval(interval);
}
}, this.delay);
},
<div>
<h3>{{ title }}</h3>
<div>{{ val }}</div>
</div>
data: () => ({
counters: [
{ start: -20, end: 69, title: 'hello, world!!', delay: 40 },
{ start: 0, end: 187, title: 'fuck the world', delay: 45 },
{ start: 400, end: 666, title: 'fuck everything', delay: 20 },
],
}),
<v-counter
v-for="n in counters"
v-bind="n"
/>
data: () => ({
width: 0,
}),
computed: {
itemSize() {
return this.width > 700 ? 46 : 56;
},
},
methods: {
onResize() {
this.width = window.innerWidth;
},
},
created() {
this.onResize();
window.addEventListener('resize', this.onResize);
},
beforeDestroy() {
window.removeEventListener('resize', this.onResize);
},
// или
data: () => ({
itemSize: null,
}),
created() {
const mql = window.matchMedia('(max-width: 700px)');
const onChange = () => this.itemSize = mql.matches ? 56 : 46;
onChange();
mql.addEventListener('change', onChange);
this.$on('hook:beforeDestroy', () => mql.removeEventListener('change', onChange));
},
:item-size="itemSize"
const ceil = (value, precision) => Math.ceil(value / precision) * precision;
const values = [ 1, 2, 3, 163, 200.001, 99.999 ];
values.map(n => ceil(n, 1)); // [ 1, 2, 3, 163, 201, 100 ]
values.map(n => ceil(n, 10)); // [ 10, 10, 10, 170, 210, 100 ]
values.map(n => ceil(n, 5)); // [ 5, 5, 5, 165, 205, 100 ]