简体   繁体   English

Vuetify; 获取v-select字段的根元素

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

In a vuetify driven project i have the following select select element; 在vuetify驱动的项目中,我具有以下select select元素;

<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.. SaveChange2事件中,我需要获取属性“ field”的值,但是由于event.target不是sending元素的子元素,因此我不知道该怎么做。

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. 这样,它将以event作为第一个参数,然后将您发送的任何内容作为第二个参数执行。

In your case (and I assume you use two @@ due to some template engine): 在您的情况下(由于模板引擎,我假设您使用两个@@ ):

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

And SaveChange2 could be: SaveChange2可能是:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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