Вариант добавить в лоб, как я сделал это выше class='test', не сработал.
Этот класс применился к input. А мне нужно применить класс к самому select, который появляется перед закрывающим тегом body.
Array.from(new Set(arr.flat()))
// или, без создания промежуточного массива
[...arr.reduce((acc, n) => (n.forEach(m => acc.add(m)), acc), new Set)]
Object.keys([].concat(...arr).reduce((acc, n) => (acc[n] = 1, acc), {}))
// или
Array.prototype.concat.apply([], arr).filter((n, i, a) => i === a.indexOf(n))
// или
`${arr}`.split(',').reduce((acc, n) => (acc.includes(n) || acc.push(n), acc), [])
// или
String(arr).match(/\w/g).sort().filter((n, i, a) => n !== a[i - 1])
// или
arr.toString().match(/(\w)(?!.*\1)/g) || []
function someFunction([ ,,, id,, status ]) {
function someFunction({ 3: id, 5: status }) {
this
внутри обработчика клика? Не тем, что вам кажется. Замените $(this).attr("href")
на $(event.target).attr("href")
или стрелочную функцию на обычную. msg.razd
массив значений:const arr = Object.values(msg.razd);
.const categories = arr.flatMap(n => n.category);
// или
const categories = [].concat.apply([], arr.map(n => n.category));
// или
const categories = arr.reduce((acc, n) => (acc.push(...n.category), acc), []);
const result = categories.filter(n => expect.includes(n._id));
// или
const result = categories.filter(function(n) {
return this.has(n._id);
}, new Set(expect));
// или
const categoriesObj = Object.fromEntries(categories.map(n => [ n._id, n ]));
const result = expect.reduce((acc, n) => ((n = categoriesObj[n]) && acc.push(n), acc), []);
setTimeout((current) => pika[current].classList.toggle('active'), 100, current)
@click="openModal(message)"
data: () => ({
openedMessage: {},
...
}),
methods: {
openModal(message) {
this.openedMessage = message;
this.showMessageModal = true;
},
...
},
<span class="box-title">{{ openedMessage.какоеТамУВасСвойствоОтвечаетЗаЭтотTitle }}</span>
...
<div class="box-body">{{ openedMessage.нуТутТожеВамВиднееЧтоНаписать }}</div>
Vue cannot detect the following changes to an array <...> When you directly set an item with the index
this.terain[x][y] = Number(this.cursorBlock)
this.$set(this.terain[x], y, +this.cursorBlock);
// или
this.terain[x].splice(y, 1, this.cursorBlock | 0);
const $test = $('.test').on('click', '.testText', function() {
$test.append($(this).clone());
});
$('.testText').click(function() {
$('.test').append($(this).clone(true));
});