Closed mrpaulharris closed 3 years ago
I think you can add your current index from your loop to id
<div v-for="idx in [1,2,6,7 ]" :key="idx" >
<v-form-base
:id="'form-base' + idx"
:model="myModel"
:schema="mySchema"
@input="log"
/>
</div>
....
log({index}) {
// over index you can select 1,2,6,7
}
Thank you, that helped me to implement a SAVE function to toggle the button loading and disabled attributes, like this:
<v-form-base
:id="'form-base' + i"
:row="{ noGutters: false }"
:col="{ cols: 12 }"
:model="configItem"
:schema="configschema"
@input="change"
/>
<v-btn type='button' color='primary' class="float-right my-4"
:loading="loading[i]"
:disabled="isdisabled[i]"
@click='save(i)'>Save</v-btn>
With the change()
function defined as
change({ index }){
// this.isdisabled[index[0]] = false; Array updates like this are not reactive, so do this...
this.$set(this.isdisabled, index[0], false)
},
It took me at least an hour to figure out that updating an array directly is NOT reactive in Vue. The workaround is to use $set()
as described in the Vue documentation.
Hope that helps somebody.
I am using in a for loop:
How can I pass change event, the index (i) value of the v-for loop, so I can access the correct
<v-form-base>
element?I have tried
index
andid
andparams
, but I just couldn't find a way, eg: