data: () => ({
selected: null,
items: [
{ title: 'hello, world!!', value: '' },
{ title: 'fuck the world', value: '' },
{ title: 'fuck everything', value: '' },
],
}),
<div v-for="n in items">
<label>
<input type="radio" :value="n.title" v-model="selected">
{{ n.title }}
</label>
<input type="text" v-model="n.value" :disabled="selected !== n.title">
</div>
const result = arr.reduce((acc, n, i) => {
if (здесь вы проверяете элемент массива на соответствие своему условию) {
let group = acc[acc.length - 1];
if (!group || group.index !== i - 1) {
group = { data: [] };
acc.push(group);
}
group.index = i;
group.data.push(n);
}
return acc;
}, []).map(n => n.data);
.fade-leave-active {
transition: opacity 1s;
}
.fade-leave-to {
opacity: 0;
}
mounted() {
this.show = false;
},
phone.value = phone.value.replace(/[^+0-9]/g, '').slice(0, 11);
const canvas = document.querySelector('#canvas');
const ctx = canvas.getContext('2d');
const TILE_SIDE = 32;
let pickX = 0;
let pickY = 0;
const ground = new Image();
ground.src = 'Ground.png';
const pick = new Image();
pick.src = 'Pick.png';
document.addEventListener('keydown', function(e) {
switch (e.keyCode) {
case 87: pickY -= TILE_SIDE; break;
case 65: pickX -= TILE_SIDE; break;
case 83: pickY += TILE_SIDE; break;
case 68: pickX += TILE_SIDE; break;
default: return;
}
draw();
});
function draw() {
for (let x = 0; x < canvas.width; x += TILE_SIDE) {
for (let y = 0; y < canvas.height; y += TILE_SIDE) {
ctx.drawImage(ground, x, y);
}
}
ctx.drawImage(pick, pickX, pickY);
}
draw();
<div class="accordionFaq"></div>
const playersOptions = [
{ source: '...' },
{ source: '...' },
...
];
$('.accordionFaq').html(playersOptions.map((n, i) => `
<div class="accordionFaq-item">
<div class="accordionFaq-head js-accordionFaq-head">
Video #${i}
</div>
<div class="accordionFaq-body">
<div id="player${i}"></div>
</div>
</div>
`).join('')).on('click', '.accordionFaq-head', function(e) {
const index = $(this).closest('.accordionFaq-item').index();
$('.accordionFaq-item', e.delegateTarget).each(function(i) {
const
$this = $(this),
isClicked = i === index,
active = isClicked && !$this.hasClass('active');
$(this)
.toggleClass('active', active)
.find('.accordionFaq-body')
[isClicked ? 'slideToggle' : 'slideUp']();
playersOptions[i].player[active ? 'play' : 'pause']();
});
});
playersOptions.forEach((n, i) => {
n.player = new Clappr.Player({
source: n.source,
parentId: `#player${i}`,
});
});
<Wrapper itemHeight="300px">
height: ${p => p.itemHeight};
будет height: ${p => p.itemHeight || '200px'};
, например. Или можно переписать компонент так:export const Wrapper = styled.article(({
itemWidth,
itemHeight = '200px',
}) => ({
backgroundColor: '#efefef',
margin: '5px',
height: itemHeight,
width: itemWidth,
}));
const ItemComponent = props => (
<div>
<p>{props.title}</p>
</div>
);
...
<Carousel
items={items}
ItemComponent={ItemComponent}
/>