简体   繁体   中英

Vuetify; get the root element of a v-select field

In a vuetify driven project i have the following select select element;

<v-select 
        v-model="$root.$data.currentStudent.LivingConditions" 
        :disabled="!editing" 
        :items="$root.$data.livingconditions" 
        field="@SecurityHelper.SimpleCrypt("LivingConditions")"
        label="Bopæl" item-text="text" item-value="value" 
        @@change="SaveChange2"
></v-select>

In the SaveChange2 event I need to get the value of the attribute "field", but as the event.target is not a child of the sending element, I can't figure out how to do this..

Any suggestions?

You can send arguments to a handler as follows:

@change="handler($event, someArg)"

This way it will be executed with the event as first argument and whatever you send as second.

In your case (and I assume you use two @@ due to some template engine):

@@change="SaveChange2($event, $root.$data)"

And SaveChange2 could be:

methods: {
  SaveChange2(evt, data) {
    console.log('event is', evt);
    console.log('field is', data.field); // equivalent to $root.$data.index
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM