当我改变所选的值时,函数不运行。我该如何解决这个问题?这是我的代码:
<q-select
v-model="single"
:options="['def', 'abc', '456', '123']"
use-chips
label="Select One"
@input="showChannel()"
/>
JavaScript 代码:
methods: {
showChannel(val) {
console.log(val);
}
}
当我改变所选的值时,函数不运行。我该如何解决这个问题?这是我的代码:
<q-select
v-model="single"
:options="['def', 'abc', '456', '123']"
use-chips
label="Select One"
@input="showChannel()"
/>
JavaScript 代码:
methods: {
showChannel(val) {
console.log(val);
}
}
请使用@update:model-value
替代@input
。(我使用了Quasar v2.0.3)
所以,您的情况如下:
<q-select
v-model="single"
:options="['def', 'abc', '456', '123']"
use-chips
label="Select One"
// @update:model-value instead of @input
@update:model-value="showChannel()"
/>
有时候,Quasar 很棘手。<q-select
v-model="single"
:options="['def', 'abc', '456', '123']"
use-chips
label="Select One"
// @update:model-value instead of @input
@update:model-value="val => showChannel(val)"
/>
对于那些使用Quasar v2的人,他们将事件从input更改为input-value