const filterArrByObj = (arr, obj) =>
Object.entries(obj).reduce((arr, [ k, v ]) => {
return arr.filter(Array.isArray(v)
? n => v.includes(n[k])
// !v.length || v.includes(n[k]), если при пустом массиве допустимо любое значение
: n => v === n[k]
// n[k].includes(v), если точное соответствие не нужно
);
}, arr);
computed: {
filteredData() {
return filterArrByObj(this.data, this.filters);
},
},
<tr v-for="n in filteredData">
...
Object
.entries({ defaultTest, systemTest })
.flatMap(([ k, { references, ...n } ]) => references.map(m => ({
...m,
...n,
[k]: true,
})))
Object
.entries({ defaultTest, systemTest })
.map(([ k, v ]) => v.map(({ references, ...n }) => references.map(m => ({
...m,
...n,
[k]: true,
}))))
.flat(2)
this.getPictures()
должно быть что-то вродеthis.collections.splice(this.collection.findIndex(n => n.id === picId), 1)
updatePost(title: string, url: string, id:number): void { const update: Picture[] = this.collection.map((p)=>{ p.id = id; p.title = title; p.url = url }); }
Object.assign(this.collection.find(n => n.id === id), { title, url });
editPost(picId: Picture[]): void { this.edData = picId; }
<button (click)="updatePost(titleEd.value, urlEd.value, edData.id);
const id = Math.max(0, ...this.collection.map(n => n.id)) + 1;
removePost(picId: number) {
this.remove.emit(picId);
}
removePost(picId: number) {
this.collection = this.collection.filter(p => p.id !== picId);
}
this.items.edit.fname; // Uncaught TypeError: Cannot read property 'fname' of undefined
this.items.rubbish.fname; // Uncaught TypeError: Cannot read property 'fname' of undefined
if (elem == "edit") { app.UserBook.fullView(elem);
fullView(elem) { const d = document; const i = elem; d.querySelector('#Edname').value = this.items[i].fname;
for (let i = 0; i < this.items.length; i++) {
table.innerHTML += `<tfoot><tr id="total-price"><td colspan="3">Total price:
${shop.totalProductsPrice}</td></tr></tfoot>`;
table.innerHTML += some;
, равносилен table.innerHTML = table.innerHTML + some;
NaN === ""
возвращает false.