18 элементов tbody <...> недопустимо
div внутри tbody
нужно сделать один циклом
state.products
, вы передаёте в addBasket
его name
. Исправьте вызов addBasket
; если же там всё так, как и задумано, замените прямое обращение по имени свойства (state.products[action.payload]
) на поиск нужного объекта по его name
:Object.values(state.products).find(n => n.name === action.payload)
const result = arr1.filter(function(n) {
return this.some(m => m.every(([ k, v ]) => v === n[k]));
}, arr2.map(Object.entries));
to
зависящим от текущего маршрута:computed: {
catalogRoute() {
return {
name: 'catalog',
params: {
module: this.$route.name === 'catalog'
? this.$route.params.module.replace(/\d+/, m => +m + 1)
: 'view-1',
},
};
},
},
<router-link :to="catalogRoute">
undefined
, вместо которого с помощью nullish coalescing подставляем просто цену. А чтобы не копипастить извлечение цены, вынесем его в отдельную функцию, которую, как и сам сортируемый массив, можно сделать параметром функции сортировки.const sorted = (arr, key) => arr
.map(n => [ n, key(n) ])
.sort((a, b) => a[1] - b[1])
.map(n => n[0]);
const sortedArr = sorted(arr, n => -(n.price.new ?? n.price).replace(/\D/g, ''));
export const store = new Vuex.Store({
на export default new Vuex.Store({
. Или import store from './store';
на import { store } from './store';
.function updateClasses({ $el, slides, activeIndex }) {
$el.find('.swiper-slide-prev-prev').removeClass('swiper-slide-prev-prev');
slides.eq(activeIndex).prev().prev().addClass('swiper-slide-prev-prev');
$el.find('.swiper-slide-next-next').removeClass('swiper-slide-next-next');
slides.eq(activeIndex).next().next().addClass('swiper-slide-next-next');
}
on: {
init() {
updateClasses(this);
},
slideChange() {
updateClasses(this);
},
},
vowelsCount = Hash['aeiou'.chars.map{|n| [ n, 0 ]}]
gets.chomp.chars.each{|n| vowelsCount[n] += 1 if vowelsCount.key?(n)}
print(vowelsCount)
const uniqueObj = (obj, key = val => val) =>
Object.fromEntries(Object
.entries(obj)
.filter(function(n) {
const k = key(n[1], n[0]);
return !this.has(k) && this.add(k);
}, new Set)
);
Int(stringValue)
. Правда, вам это не сильно поможет - есть ещё косяки. Можете попытаться исправить их самостоятельно.func worthSum(count: String, worth: [Int]) -> Int {
return count.split(separator: " ").enumerated().reduce(0, { acc, n in
acc + (Int(n.1) ?? 0) * worth[n.0]
})
}
func evaluate(good: String, vsEvil evil: String) -> String {
let g = worthSum(count: good, worth: [ 1, 2, 3, 3, 4, 10 ])
let e = worthSum(count: evil, worth: [ 1, 2, 2, 2, 3, 5, 10 ])
return g == e
? "Battle Result: No victor on this battle field"
: g > e
? "Battle Result: Good triumphs over Evil"
: "Battle Result: Evil eradicates all trace of Good"
}
@input="$emit('input', $event.target.value)"
, или сделайте вычисляемое свойство:innerValue: {
get() {
return this.value;
},
set(val) {
this.$emit('input', val);
},
},
<select v-model="innerValue">
const getMaxIndexes = (arr, count) => Object
.entries(arr.reduce((acc, n, i) => ((acc[n] = acc[n] ?? []).push(i), acc), {}))
.sort((a, b) => b[0] - a[0])
.flatMap(n => n[1])
.slice(0, count);
$slider.find('.ul-slider-handle').html(`<img src="${imageSrc}">`);
slide(e, ui) {
$(this).find('.ui-slider-handle img').css('opacity', в зависимости от ui.value);
},
<div data-color="black"></div>
<div data-color="white"></div>
document.addEventListener('click', ({ target: { dataset: { color } } }) => {
if (color) {
document.querySelector('button').dataset.id = color;
}
});
// или
const button = document.querySelector('button');
const onClick = e => button.setAttribute('data-id', e.target.getAttribute('data-color'));
document.querySelectorAll('[data-color]').forEach(n => n.addEventListener('click', onClick));
.container {
background: #224B7A;
}
.container.active {
background: #fff;
}
state = {
active: false,
}
toggleActive = ({ type }) => {
this.setState(() => ({
active: type === 'focus',
}));
}
<div className={`container ${this.state.active ? 'active' : ''}`}>
...
<input onFocus={this.toggleActive} onBlur={this.toggleActive} />