Why is data in Vue component a function?

Time:2020-9-25

 

1、 Why is data in Vue component a function

In order to ensure the independence and reusability of components, data It is a function. When a component is instantiated, this function will be called to return an object. The computer will assign a memory address to this object. If you instantiate it several times, you will allocate several memory addresses. Their addresses are different. Therefore, the data in each component will not interfere with each other. Changing the state of one component will not change the other components.

  

 

 

 

 

 

 

Author: Jin Feifei
Mobile phone number (wechat synchronization): 17812718961
I hope this article can bring harvest to friends who are learning front end or work. If you don’t like it, please don’t spray. If you have suggestions, please give me more suggestions. Thank you!!!