v-on:keyup 不触发功能

Jas*_*yer 5 vuejs2

由于某种原因,我无法触发我的 keyup 事件。我希望它在尝试创建实时搜索功能时收听任何和所有 keyup 事件

这是我的代码:

<template>
...
<b-form-input id="search"
              v-model="query"
              type="text"
              placeholder="Search"
              v-on:keyup="find(search, query)">
</b-form-input>

....

</template>

<script type="text/javascript">
export default {
data() {
  return {
    options: [
        { text: 'All', value: 'All' },
        { text: 'Members', value: 'Members' },
        { text: 'Groups', value: 'Groups' },
        { text: 'Events', value: 'Events' }
    ],
    search: 'All',
    query: '',
    results: []
  }
},

methods: {
    find: function (param = 'All', string = '') {
        axios.get('/api/search/' + param.toLowerCase() + '?query=' + string)
    .then(({data}) => {
        this.results = data.data;
    });
    }
}}
</script>
Run Code Online (Sandbox Code Playgroud)

我只能执行 v-on:change 来启动它。

Jac*_*Goh 8

b-form-input只支持inputchange事件。

要使用 keyup 事件侦听器,请将.native添加到其中。

@keyup.native="..."
Run Code Online (Sandbox Code Playgroud)

来自https://bootstrap-vue.js.org/docs/components/form-input#component-reference

在此处输入图片说明

  • 对于将来来到这里的任何人,输入的示例如下所示:`@keyup.enter.native =“yourMethod”` (3认同)