我有一個基本的文本欄位,它在按鍵時會將搜索請求發送到后端。
<template>
<v-form
ref="form"
>
<v-text-field
v-model="deviceId"
label="Search"
required
clearable
name="searchInput"
@keyup.native="updateStore"
/>
</v-form>
</template>
這是腳本
device : string | undefined = undefined
get deviceId () : string | undefined {
if (this.device === undefined) {
this.device = store.selectedDevice
}
return this.device
}
set deviceId (value : string) {
store.selectDevice(value)
this.device = value
}
updateStore (value: string): void {
console.log(value)
store.selectDevice(value)
}
問題是它不會發送對搜索中輸入的所有字符的請求。所以如果我輸入“ping”,查詢只會發送query=p. 但是,如果我將字串復制粘貼到搜索欄中,則會發送query=ping.
不確定要使用哪個 vueitfy 事件或模板結構是否不正確?
uj5u.com熱心網友回復:
嘗試使用input事件而不是keyup:
<template>
<v-form
ref="form"
>
<v-text-field
v-model="deviceId"
label="Search"
required
clearable
name="searchInput"
@input="updateStore"
/>
</v-form>
</template>
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/334965.html
標籤:javascript 打字稿 Vue.js vuetify.js
下一篇:如何使用jquery預填充欄位
