Vue.js多选-键盘事件如“ Ctrl + Enter”键按下不起作用

时间:2019-05-09 09:13:13

标签: vue.js vue-multiselect

我正在使用此库https://vue-multiselect.js.org/,并尝试为ctrl + enter添加自定义事件处理程序。 我尝试了所有活动,例如键,键按下,按键和键,例如ctrl,enter,ctrl.enter等,类似于:

@keyup.ctrl.enter="selectItemKeyboard"
@keydown.ctrl.enter="selectItemKeyboard()"
@keypress.ctrl.enter="selectItemKeyboard($event)"
v-on:keyup.ctrl.enter="selectItemKeyboard"
v-on:keydown.ctrl.enter="selectItemKeyboard($event)"
v-on:keypress.ctrl.enter="selectItemKeyboard()"

实际代码:

<multiselect
    v-model="searchItem"
    label="name"
    track-by="title"
    placeholder="Find something…"
    open-direction="bottom"
    name="search"
    ref="search"
    :options="searchResults"
    :searchable="true"
    :internal-search="false"
    :clear-on-select="false"
    :max-height="600"
    :preserveSearch="true"
    :show-no-results="false"
    :show-no-options="false"
    :loading="isLoading"
    @search-change="search"
    @select="selectItem"
    @keyup.ctrl.enter="selectItemKeyboard"
>

selectItemKeyboard(item: any) {
    console.log(item)
}

该方法从不执行。我怀疑控件会吞下事件,因为它以用户的形式处理实际的输入,但是找不到解决方法。

0 个答案:

没有答案