v-autocomplete在Vuetify 3中失去了”change event”吗?

huangapple go评论57阅读模式
英文:

v-autocomplete lost "change event" in vuetify 3?

问题

在Vuetify 2中,v-autocomplete组件有一个名为change event的事件。示例:

<v-autocomplete
    label="Choose stock"
    v-model="selected_stock"
    :items="current_stocks"
    :change="stockSelected"
    item-value="id"
    item-title="name"
></v-autocomplete>

stockSelected(selected_stock) {
    console.log(selected_stock);
}

在Vuetify 3中,似乎不再存在这个事件。我该如何在Vuetify 3中跟踪选择更改

英文:

In Vuetify 2 there was a change event for the v-autocomplete component. An example:

&lt;v-autocomplete
	label=&quot;Choose stock&quot;
	v-model=&quot;selected_stock&quot;
	:items=&quot;current_stocks&quot;
	:change=&quot;stockSelected&quot;
	item-value=&quot;id&quot; 
	item-title=&quot;name&quot;&gt;&lt;/v-autocomplete&gt;

stockSelected(selected_stock) {
   console.log(selected_stock);
}

In Vuetify 3 this event doesn't seem to exist anymore. How can I track a selection change in Vuetify 3?

答案1

得分: 3

我猜测@change事件被移除了,因为它是多余的,你可以只监听@update:modelValue事件:

<v-autocomplete
    v-model="selected_stock"
    @update:modelValue="stockSelected"
    ...
></v-autocomplete>
英文:

I guess the @change event was removed because it is redundant, you can just listen to the @update:modelValue event:

&lt;v-autocomplete
    v-model=&quot;selected_stock&quot;
    @update:modelValue=&quot;stockSelected&quot;
    ...
&gt;&lt;/v-autocomplete&gt;

huangapple
  • 本文由 发表于 2023年6月16日 00:34:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76483768.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定