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));
});
this.$store.dispatch({type:'ADD_CONTACT'}, payload)
actions:{ addContact:
this.$store.dispatch({
type: 'addContact',
payload,
});
actions: {
addContact: ({ commit }, { payload }) => commit('ADD_CONTACT', payload),
},
this.$store.commit('ADD_CONTACT', payload)
. Код компонента где хранятся все посты:
@click="addPostToHistoryComp(post.id, post.title, post.body)"
paginatedData() { const start = this.page * 6;
addPostToHistoryComp(val){ this.$store.dispatch('transforPostToHistoryComp', { pTitle: val.post.title,
<li v-for="(historyPost, index) in historyPosts" class="post" :key="index"> <img src="src/assets/nature.jpg"> <p class="boldText"> {{ post.title }}</p>
const todohistory = { title: payload.pTitle, body: payload.pBody, id: payload.pId } commit('ADD_TODO_HISTORY', todo)
ADD_TODO_HISTORY (state, todohistoryObject) { state.historyPosts.unshift(todoObject) },
data-country
почему-то на русском - какого чёрта? Надо, чтобы были такими же, как и id
у элементов .tabcontent
.const tabLinks = document.querySelectorAll('.tablinks');
const tabContent = document.querySelectorAll('.tabcontent');
tabLinks.forEach(n => n.addEventListener('click', openTab));
function openTab({ currentTarget: t }) {
const { country } = t.dataset;
tabLinks.forEach(n => n.classList.toggle('active', n === t));
tabContent.forEach(n => n.classList.toggle('active', n.id === country));
// или, к чёрту data-атрибуты и id, можно индексами воспользоваться;
// конечно, в этом случае необходимо, чтобы .tablinks и соответствующие им
// .tabcontent были расположены в одинаковом порядке
const index = Array.prototype.indexOf.call(tabLinks, t);
tabLinks.forEach(n => n.classList.toggle('active', n === t));
tabContent.forEach((n, i) => n.classList.toggle('active', i === index));
}
placemark.events.add('click', () => {
// здесь дёргаете scrollTo или scrollIntoView
});
<button v-for="(n, i) in items" @click="onClick(i)">{{ n }}</button>
methods: {
onClick(index) {
this.items = this.items.slice(0, index + 1);
// или
// this.items.splice(index + 1, this.items.length - index);
},
...
},
const info = new google.maps.InfoWindow();
marker.addListener('click', function() {
info.setContent('сюда засовываете свою информацию');
info.open(map, marker);
});