Pass input parameter to function

1

I ran into a problem, to pass the value of my input to my function without using v-model .

I know it works that way

<Input @click="func" />

func(val){
   alert(val)
}

But I can not pass another parameter, eg: <Input @click="func(status)" /> , in this way it will only receive the value I passed, but I would like to be able to pass the value that is in the input, more parameters of my choice .

    
asked by anonymous 21.12.2017 / 17:44

1 answer

1

You can send multiple parameters to the function, with $event sending properties of the element, which you can capture with currentTarget :

var campo = new Vue({
  el: '#teste',
  methods: {
     func: function (a, e) {
       alert(a +"/"+ e.currentTarget.value);
     }
  }
});
<script src="https://cdn.jsdelivr.net/npm/vue"></script><Inputvalue="olá!" id="teste" @click="func('status', $event)" />
    
21.12.2017 / 18:42