VueJs, difference between computed property and watcher?

前端 未结 6 1090
孤街浪徒
孤街浪徒 2020-12-09 01:24

On Vue.js documentation there is an example like below:

var vm = new Vue({
  el: \'#demo\',
  data: {
    firstName: \'Foo\',
    lastName: \'Bar\',
    full         


        
6条回答
  •  生来不讨喜
    2020-12-09 02:05

    watch

    Use watch when you want to perform asynchronous or expensive operations in response to changing data.

    computed

    Use computed in other cases. The computed properties are cached based on their dependencies. Mostly used when you want to only re-evaluate some of its dependencies have changed.

提交回复
热议问题