Method vs Computed in Vue

后端 未结 7 554
说谎
说谎 2020-11-28 01:00

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

They look the same and interchangeable.

7条回答
  •  广开言路
    2020-11-28 01:37

    From the docs

    ..computed properties are cached based on their dependencies. A computed property will only re-evaluate when some of its dependencies have changed.

    If you want data to be cached use Computed properties on the other hand if you don't want data to be cached use simple Method properties.

提交回复
热议问题