Computed Property in Vue.js

August 31, 2019

What is computed property?

This can be considered as property of the data object or methods
you can access them as if they were properties of the data object, but you define them as functions.

Property of the data object

  <p>{{ count }}</p>

export default {
  data() {
    return {
      count: 1

Why do you need computed property?

The computed properties are cached and when you run the method several time cached value will be returned.
When the dependencies inside the computed property changes, the method will be executed again to return the new value

But normal method will be executed every time when it is called