<div
v-for="item in splitComments"
:key="item.id"
class="comment-item"
>
...
<span
class="comment-text"
v-for="(str, i) in item.textList"
:class="{highlight: i%2}"
>
{{ str }}
</span>
</div>
computed: {
splitComments() {
return this.comments.map(item => ({
...item,
textList: item.text.split(/(@\S+)/)
}))
}
}
.highlight {
color: white;
background: red;
}
methods: {
highlightNames: str => str.replace(/(?<=^|\s)@\S+/g, '<span class="highlight">$&</span>'),
},
<div v-html="highlightNames(item.text)"></div>
const store = new Proxy({
a: 50
}, {
set(target, property, value, receiver) {
console.log(`Поле <${property}> было обновлено. Новое значение:`, value);
return Reflect.set(target, property, value, receiver);
}
});
store.a = 10;
// Поле <a> было обновлено. Новое значение: 10
box-shadow: inset 0 3px 5px 0 rgba(0,0,0, 0.21);
function filterObjectProps<O extends Record<string, unknown>, P extends keyof O>(obj: O, props: readonly P[]) {
const entries: [P, O[P]][] = [];
for(const prop of props) {
if(prop in obj) {
entries.push([prop, obj[prop]]);
}
}
return Object.fromEntries(entries) as {
[K in P]: O[K];
};
}
// ...
updateItem(id: string, updateItemDto: UpdateItemDto): Item {
const item = this.getItemById(id);
return {
...item,
...filterObjectProps(updateItemDto, ['name', 'lastname', 'prop1', 'prop2'])
};
}
.carousel-control-next-icon {
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 8 8'%3e%3cpath d='M2.75 0l-1.5 1.5 2.5 2.5-2.5 2.5 1.5 1.5 4-4-4-4z'/%3e%3c/svg%3e");
}