What is the main difference between a method and a computed value in Vue.js?

Technology CommunityCategory: Vue.jsWhat is the main difference between a method and a computed value in Vue.js?
VietMX Staff asked 3 years ago

Computed values and methods are very different in Vue and are definitely not interchangeable in most cases.

  • A more appropriate name for a computed value is a computed property. You can think of a computed value as a derived value that will be automatically updated whenever one of the underlying values used to calculate it is updated.
  • method is just a function bound to the Vue instance. It will only be evaluated when you explicitly call it.