v-on:change不适用于vue-multiselect

Cia*_*arz 3 vue.js vue-component vuejs2 vue-events

我正在vue.js项目中使用vue-multiselect组件,正在使用v-on指令在change事件上执行功能,

<multiselect v-model="selected" :options="projects" :searchable="false" :custom-label="customLabel" track-by="name" v-on:change="executeLoader">
<template slot="customLabel" slot-scope="{ customLabel }"><strong>{{ option.name }}</strong></template>   
</multiselect>
Run Code Online (Sandbox Code Playgroud)

我在这里有完整的示例代码:https : //codesandbox.io/s/yjjon0vzxj

v-on:change正在使用<select>组件,但它停止了vue-multiselect的工作!我尝试过,v-on:click="executeLoader"但是也没有用。

Oma*_*nti 5

@click不会executeLoader通过vue multiselect 触发该方法。您可以使用@input-这是类似的v-on:change@close@select如下面的例子中:

<multiselect placeholder="Pick at least one" select-label="Enter doesn’t work here!" :value="value" :options="options" :multiple="true" :searchable="true" :allow-empty="false" :hide-selected="true" :max-height="150" :max="3" :disabled="isDisabled" :block-keys="['Tab', 'Enter']" @input="onChange" @close="onTouch" @select="onSelect"></multiselect>
Run Code Online (Sandbox Code Playgroud)

在您的情况下,我会尝试 @input="executeLoader"