【问题标题】:Vuetify search on keypressVuetify 按键搜索
【发布时间】:2021-12-10 10:23:17
【问题描述】:

我有一个基本的文本字段,在按键时会将搜索请求发送到后端。

<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 事件或模板结构是否不正确?

【问题讨论】:

    标签: javascript typescript vue.js vuetify.js


    【解决方案1】:

    尝试使用input 事件而不是keyup

    <template>
      <v-form
        ref="form"
      >
        <v-text-field
          v-model="deviceId"
          label="Search"
          required
          clearable
          name="searchInput"
          @input="updateStore"
        />
      </v-form>
    </template>
    

    【讨论】:

      猜你喜欢
      • 2013-11-23
      • 2019-12-13
      • 2018-12-04
      • 2011-11-05
      • 2013-04-02
      • 1970-01-01
      • 1970-01-01
      • 2019-03-21
      • 2021-12-12
      相关资源
      最近更新 更多