E
E
Evgeniy2019-02-13 12:36:58
Vue.js
Evgeniy, 2019-02-13 12:36:58

Vue.js: How to subscribe to an event on the root element of a component, only on one instance?

There is a repeatedly used component of the button.
It is necessary to assign a method to each of the buttons when pressed.
It is not possible to subscribe to the Click event using this implementation:

<v-icon-button v-on:click="dosomething"></v-icon-button>

What are the ways? The component template is something like this:
<button class="icon-button"><slot></slot></button>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-02-13
@zhenya31

Subscribe to a native event: Or fire an event in a component:

<button class="icon-button" @click="$emit('click')">

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question