Answer the question
In order to leave comments, you need to log in
How to fire 2 @click events in Vue.js?
Using the Vuetify 2 library, the Item Groups component , but this task will work for all elements with toggle.
Posted the code here .
The objectives of the task are as follows:
1) On the @click="toggle" event, perform one more action (write the key into Vuex). I know that you need to create a method for this, but how to write this toggle action in the method?
2) How to assign an element index identical to the key property in the items array? I need to pass in Vuex not 0, 1 or 2, but the key property of the selected element.
Answer the question
In order to leave comments, you need to log in
You can simply list the methods separated by commas:
*For toggle to work, you need to pass the $event event object, by default, when one method is registered, $event is passed automatically
div(@click="multiplyActions")
methods: {
multiplyActions() {
this.foo();
this.bar();
this.baz();
},
foo() {
console.log(123213);
},
.....
}
In the example code, you are moving in the normal direction.
Nothing prevents you from expanding the logic of the method.
if suddenly someone needs it, this is how you can do 2 methods for 1 event
<div
@click="sendRequest('DELETE', {ids: [deleteModal.itemId]}); deleteModal.show = false"
></div>
In VUE3, the variant did not work for me: @click="foo, bar"
But it works fine, immediately with the call: @click="foo(), bar()"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question