Consider the following fragment in a <template>:
<div v-for="entry in entries">
<my-component :color="doSomething(entry)">hello</my-component>
</div>
The related method:
doSomething(entry) {
return entry.color
}
Is there a way to replace the setup above with a computed property without the need to pass (entry) each time? Something like:
<div v-for="entry in entries">
<my-component :color="doSomething">hello</my-component>
</div>
The related method:
doSomething() {
// I need to know here that the call is coming from <my-component>
// in the context of "entry"
return ???.color
}
The reason for the question is that I would like to reduce the boilerplate for components that rely on the state of an iterated property:
<q-editor
v-for="note in notesByDay[when]"
@click="noteClicked(note)"
@blur="noteBlurred(note)"
:toolbar="SetToolbar(note)"
(...)