data: () => ({
active: null,
items: [
{ text: 'hello, world!!', numSpans: 3, classes: [] },
{ text: 'fuck the world', numSpans: 6, classes: [ 'yyy' ] },
{ text: 'fuck everything', numSpans: 0, classes: [ 'zzz' ] },
],
}),
<ul>
<li v-for="(n, i) in items" :class="{ active: active === i }">
<a :class="[ 'xxx', ...n.classes ]" @click="active = i">
{{ n.text }}
<span v-for="s in n.numSpans"></span>
</a>
</li>
</ul>
.active {
background: red;
}
this.setState(newState, () => {
// вот здесь
})
.catch(this.handleError)
.catch(err => this.handleError(err))
const result = elements.filter(n => !used.some(m => m.id === n.id));
const result = elements.filter(((ids, n) => !ids.includes(n.id)).bind(null, used.map(n => n.id)));
const result = elements.filter(function(n) {
return !this.has(n.id);
}, new Set(used.map(n => n.id)));
const result = Object.values(used.reduce(
(acc, n) => (delete acc[n.id], acc),
elements.reduce((acc, n) => (acc[n.id] = n, acc), {})
));
const result = [...used.reduce(
(acc, n) => (acc.delete(n.id), acc),
new Map(elements.map(n => [ n.id, n ]))
).values()];
$.getJSON('https://api.cdnjs.com/libraries/jquery', function(data) {
$('body').append(`<pre>${JSON.stringify(data, null, 2)}</pre>`);
});
const toHTML = val =>
val instanceof Object
? `<ul>${Object.values(val).map(n => `
<li>${toHTML(n)}</li>`).join('')}
</ul>`
: val;
fetch('https://api.cdnjs.com/libraries/jquery')
.then(r => r.json())
.then(r => document.body.insertAdjacentHTML('beforeend', toHTML(r)));
this.setState({ price: this.state.price + price, title: [this.state.title+title]});
this.setState({
price: this.state.price + price,
title: this.state.title.concat(title)
});
str_replace($alphabet, array_keys($alphabet), $str)
<button class="btn" data-hover-text="hello, world!!"></button>
.btn {
border: 0;
background: green;
display: inline-block;
width: 3em;
height: 3em;
border-radius: 1.5em;
overflow: hidden;
transition: width 0.2s linear;
}
.btn::before {
display: inline-flex;
width: 100%;
height: 100%;
color: white;
justify-content: center;
align-items: center;
white-space: nowrap;
transition: letter-spacing 0.2s linear;
letter-spacing: -2px;
content: ">";
}
.btn:hover {
width: 10em;
}
.btn:hover::before {
letter-spacing: 0px;
content: attr(data-hover-text);
}
const type = document.querySelector('#type');
const price = document.querySelector('#price');
const minPrices = {
bungalo: 0,
flat: 1000,
house: 5000,
palace: 10000,
};
type.addEventListener('change', function() {
const minPrice = minPrices[this.value];
price.min = minPrice;
price.value = Math.max(minPrice, price.value);
});
type.dispatchEvent(new Event('change'));
$('body').on('click', '.help'
$('body').on('mousedown', '.help'