0

Is it possible in VueJS to have a default click event on a custom component?

E.g. we have built a component called editable. Now on click, we always want it to fire the same function, no matter where we call that component.

<editable @click="doSomething" ...></editable>

Can I define that somewhere in the JS side?

1 Answer 1

2

In case of custom component, you need to bind to native event:

<editable @click.native="doSomething" ...></editable>

For documentation, refer to Vue.js docs here.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, that was easy :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.