How to $watch multiple variables?

后端 未结 4 1151
天命终不由人
天命终不由人 2021-02-02 17:36

I do have two $scope variables. They are called $scope.image and $scope.titleimage.

Basically the store the same type of contents.

4条回答
  •  耶瑟儿~
    2021-02-02 18:25

    Use computed and return multiple variables in an array that you want to listen to that should execute the same function.

    computed: {
      photo () {
        return [this.image, this.title]
      }
    },
    watch: {
      photo () {
        console.log('changed')
      }
    },
    

提交回复
热议问题