Vue-multiselect-无法在事件处理程序中获取事件对象

我使用Vue 2和Vue-multiselect,并且尝试使用一种事件方法,该方法要在进行一些检查之后传递一个对象和输入事件对象以能够使用preventDefault()

但是我没有得到输入事件对象,并且multiselect的工作方式似乎与Vue文档中所说的不同:

Sometimes we also need to access the original DOM event in an inline statement handler. 
You can pass it into a method using the special $event variable:

<button v-on:click="warn('Form cannot be submitted yet.',$event)">


warn: function (message,event) {
    // now we have access to the native event
    if (event) {
      event.preventDefault()
    }

如果我尝试使用以下代码:

<multiselect 
   @input="setRole(myVariable,$event)"


setRole(myVariable,event){

   console.log('event:',event);

我得到的是,而不是事件。

获取对象的唯一方法是仅传递$event,并在处理程序方法中访问$event

  <multiselect 
     @input="setRole($event)" 


setRole( $event){
   console.log('event:',$event);

但是,如果我传递另一个参数(必须执行此操作),则会获得事件值。

多选documentation并没有说太多。

那么如何获取事件对象?

liu1809 回答:Vue-multiselect-无法在事件处理程序中获取事件对象

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3057327.html

大家都在问