由于某种原因,我无法触发我的 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 来启动它。
b-form-input只支持input和change事件。
要使用 keyup 事件侦听器,请将.native添加到其中。
@keyup.native="..."
Run Code Online (Sandbox Code Playgroud)
来自https://bootstrap-vue.js.org/docs/components/form-input#component-reference
| 归档时间: |
|
| 查看次数: |
5495 次 |
| 最近记录: |