:class="form.FirstName !== null ? form.FirstName ? 'input-successes' : 'input-error' : ''"
:class="{ 'input-successes': form.FirstName, 'input-error': form.FirstName === false }"
:class="form.FirstName !== null && [ 'input-error', 'input-successes' ][+form.FirstName]"
:class="({ true: 'input-successes', false: 'input-error' })[form.FirstName]"
this.update = () => {
const w = this.w / 2;
const h = this.h / 2;
this.x = Math.max(w, Math.min(W - w, this.x + this.dx));
this.y = Math.max(h, Math.min(H - h, this.y + this.dy));
};
document.addEventListener('keydown', e => {
switch (e.key) {
case 'ArrowLeft': pl.dx = -pl.speed; break;
case 'ArrowRight': pl.dx = pl.speed; break;
case 'ArrowUp': pl.dy = -pl.speed; break;
case 'ArrowDown': pl.dy = pl.speed; break;
}
});
document.addEventListener('keyup', e => {
switch (e.key) {
case 'ArrowLeft':
case 'ArrowRight': pl.dx = 0; break;
case 'ArrowUp':
case 'ArrowDown': pl.dy = 0; break;
}
});
state = {
likes: localStorage.getItem('likes') | 0,
}
plus = () => {
this.setState(({ likes }) => ({
likes: likes + 1,
}), () => localStorage.setItem('likes', this.state.likes));
}
const tableId = 'news';
const trSelector = 'tbody tr';
$(`#${tableId}`).show().not(`:has(${trSelector})`).hide();
// или
const $table = $('[id="' + tableId + '"]');
$table.toggle(!!$table.find(trSelector).length);
(t => t.hidden = !t.querySelector(trSelector))
(document.querySelector('#'.concat(tableId)));
// или (в стили надо будет добавить .hidden { display: none; })
const table = document.getElementById(tableId);
table.classList.toggle('hidden', Array.prototype.every.call(
table.tBodies,
n => !n.rows.length
));
#news:not(:has(tbody tr)) {
display: none;
}
infinite: false
в настройках слайдера.$slick.on('beforeChange', function(e, slick, currentSlide, nextSlide) {
$(this).find('.slick-next').prop('disabled', nextSlide === slick.slideCount - 1);
});
а как ей стиль менять?
slick-disabled
, можете с его помощью переопределять их внешний вид.const attacks = [
{ minChance: 7, damage: 40, name: 'critical' },
{ minChance: 5, damage: 20, name: 'big' },
{ minChance: 0, damage: 10, name: 'weak' },
];
const messages = {
start: (player, enemy) => `Welcome! Yor health is - ${player}%, your enemy health - ${enemy}%`,
end: (player, enemy) => `You ${enemy <= 0 ? 'win' : 'lost'}! Your hp level - ${player}, opponents hp level - ${enemy}`,
chance: (player, enemy) => `your chance - ${player}, your opponent chance - ${enemy}`,
turn: (player, enemy, hit, isEnemy) =>
`${isEnemy ? 'Enemy' : 'Your'} turn...
${isEnemy ? 'Enemy' : 'You'} did a ${hit} hit
${isEnemy ? 'Your' : 'Enemy'} hp - ${isEnemy ? player : enemy}`,
};
const simpleFight = () => {
const hp = [ 100, 100 ];
console.log(messages.start(...hp));
while (hp.every(n => n > 0)) {
const chances = hp.map(() => Math.random() * 11 | 0);
console.log(messages.chance(...chances));
if (chances[0] !== chances[1]) {
const chance = Math.max(...chances);
const attack = attacks.find(n => n.minChance < chance);
const isEnemyAttacks = chance === chances[1];
hp[+!isEnemyAttacks] -= attack.damage;
console.log(messages.turn(...hp, attack.name, isEnemyAttacks));
}
}
console.log(messages.end(...hp));
};
const sum = str.match(/\d+/g).reduce((acc, n) => acc + +n, 0);
// или
let sum = 0;
for (const n of str.split(/\D+/)) {
sum += Number(n);
}
// или
const sum = eval(str.replace(/\|(\d+)\|/g, '+$1'));
preg_match_all('/\d+/', $str, $matches);
$sum = array_sum($matches[0]);
// или
$sum = 0;
foreach (preg_split('/\D+/', $str) as $n) {
$sum += intval($n);
}
// или
eval('$sum = '.preg_replace('/\|(\d+)\|/', '+$1', $str).';');
id="mse2_ms|price_0"
|
засунуть в id.#
, а как значение атрибута, т.е. [id="mse2_ms|price_0"]
. после перезагрузки страницы получаю undefined
правильно ли я возвращаю копию значения с объекта store.singleMetricNamesMap
$store.state.singleMetricNamesMap[value.metricId]
. Если так по-вашему слишком длинно - сделайте в компоненте вычисляемое свойство, которое будет представлять singleMetricNamesMap. width: 100% !important;
, а родительский элемент canvas'а карты имеет нулевые размеры.new ymaps.Map("map", {
data: () => ({
size: 52,
col: 0,
row: 0,
}),
methods: {
onMouseMove(e) {
this.col = e.offsetX / this.size | 0;
this.row = e.offsetY / this.size | 0;
},
},
computed: {
blockStyle() {
return {
backgroundSize: `${this.size}px ${this.size}px`,
};
},
blockCursorStyle() {
const { col, row, size } = this;
return {
transform: `translate(${col * size}px, ${row * size}px)`,
width: `${size * 0.95}px`,
height: `${size * 0.95}px`,
};
},
},
<div class="block" :style="blockStyle" @mousemove="onMouseMove">
<div class="block-cursor" :style="blockCursorStyle"></div>
</div>
margin-top: $margin;
@for $i from 1 through $count {
&:nth-child(#{$i}) {
margin-top: 0;
}
}
interface ItempElement {
x: number;
y: number;
};
interface Itemp extends Array<ItempElement> {};
В документации не нашёл.