javascript - What is the underlying dependency principle of Vue's calculated properties?
ringa_lee
ringa_lee 2017-06-17 09:16:34
0
2
751

If calculated property

var vm = new Vue({
  data: {
    a: 'hi',
    b:'buu',
    c: 'zzz'
  },
  computed: {
    example: {
      return  this.a + this.b
    }
  }
})

If attributes a and b change, the calculated attributes will change responsively. How is this mechanism implemented?
How to know the changes in a and b inside?

ringa_lee
ringa_lee

ringa_lee

reply all(2)
阿神

Thanks for the invitation.

I don’t know about VUE, but this change of attribute value is just like the difference between reference and valuein other languages.
Example:

Suppose the address referenced by a is 0xaaa0, and the value loaded by 0xaaa0 is 'hi0'
Change the address referenced by a to 0xaaa1, and the value loaded by 0xaaa1 is 'hi1'
Then when a is obtained, the value changes.

漂亮男人

Look at the in-depth response part of the vue documentation

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!