For those starting out learning Vue, there’s a bit of confusion over the difference between methods, computed properties and watchers.
Even though it’s often possible to use each of them to accomplish more or less the same thing, it’s important to know where each outshines the others.
In this quick tip, we’ll look at these three important aspects of a Vue application and their use cases. We’ll do this by building the same search component using each of these three approaches.
A method is more or less what you’d expect — a function that’s a property of an object. You use methods to react to events which happen in the DOM, or you can call them from elsewhere within your component — for example, from within a computed property or watcher. Methods are used to group common functionality — for example, to handle a form submission, or to build a reusable feature such as making an Ajax request.
You create a method in a Vue instance, inside the methods object: