How to call a multiple functions in single v-on
event?
No difference: click, focus or whatever?
Something like:
<div v-on:click="fn1('foo');fn2('bar')"> </div>
Or may be:
<div v-on:click="fn1('foo')"
v-on:click="fn2('bar')"> </div>
How to do it right?
UPDATE: Yes, of course I always can do
<div v-on:click="fn3('foo', 'bar')"> </div>
function fn3 (args) {
fn1(args);
fn2(args);
}
But that's really ugly.
Separate into pieces.
Inline:
OR: Through a composite function:
to add an anomymous function to do that may be an alternative:
you can, however, do something like this :
yes, by using native onclick html event.
Html:
JS:
First of all you can use the short notation
@click
instead ofv-on:click
for readability purposes.Second You can use a click event handler that calls other functions/methods as @Tushar mentioned in his comment above, so you end up with something like this :
I'm on Vue 2.3 and I can do this: