programing

v-on: 키업이 기동하지 않는 기능

prostudy 2022. 5. 28. 09:06
반응형

v-on: 키업이 기동하지 않는 기능

무슨 이유에서인지 키업 이벤트를 시작할 수 없습니다.라이브 검색 기능을 만들기 위해 키업 이벤트를 모두 듣고 싶습니다.

코드는 다음과 같습니다.

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

v-on:변화를 할 수 밖에 없었어요.

b-form-input지원만input그리고.change이벤트입니다.

키업 이벤트청취자를 사용하려면 .native를 추가합니다.

@keyup.native="..."

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

여기에 이미지 설명 입력

언급URL : https://stackoverflow.com/questions/49961625/v-onkeyup-not-firing-function

반응형