'how to commit inputs v-model, recived by v-for directive
I don't know how to commit v-models of inputs after used v-for directive. Can someone tell me ho to pass index to computed or any other way of proper way of commiting in this situation.
here is example: template part
<q-list v-for="(book, index) in $store.state.documents[docIndex].contents[contentIndex].books" :key='index'>
<q-input v-model="booksTitle"/>
</q-list>
script part
export default defineComponent({
name: 'ProductComponent',
props:{
docIndex:{
type: Number
},
contentIndex:{
type: Number
},
},
setup(props) {
const store = useStore()
let booksTitle = computed({
get: () => {
if(store.state.documents && props.docIndex && props.contentIndex)
{return store.state.documents[props.docIndex].contents[props.contentIndex].books[index].tile}//here is the tricki part
else{
return 'no document'
}},
set:( val ) => {
store.commit('ST_TITLE_MUTATION', {val , props, index})//here is also tricki part
}
})
return {
booksTitle
};
},
})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
