v-on:keyup not firing function

2019-03-01 09:18发布

For some reason I cannot get my keyup event to fire. I would like it to listen to any and all keyup events as I am trying to make a live search function

Here is my code:

<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>

I've only been able to do v-on:change to get it to fire.

标签: vuejs2
1条回答
可以哭但决不认输i
2楼-- · 2019-03-01 09:58

b-form-input only supports input and change event.

To use keyup event listener, add .native to it.

@keyup.native="..."

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

enter image description here

查看更多
登录 后发表回答