Embracing the concept of keeping component logic within itself is the essence of the component-based approach. A click listener attached to a component or its sub-element is considered personal and exclusive to that component.
Exploring Mixins
However, in scenarios where the same logic needs to be applied to multiple components, utilizing mixins is the recommended solution. It's important to note that the store is not the appropriate place for this. This holds true for any situation where there is a need to share reusable functionalities.
Aside from offering flexibility, mixins come with a range of benefits. For example, you can leverage the option merging feature of mixins to customize the onClick() method in a specific component while retaining the common logic present in the mixin.
It's crucial to be cautious as hook functions with the same name are merged into an array, ensuring that all of them are executed. Mixin hooks are invoked before the component's own hooks.
Further Exploration
For a practical demonstration, take a look at this repository: https://github.com/buefy/buefy. Buefy is a Vue.js UI components library that showcases best practices and examples, serving as a valuable resource for improving code quality.