Passing friends, you can click a like, pay attention to ~~~
1. The difference between calculation attributes and methods?
- The computed cache
- Methods in computed mainly generate new data based on data in data, and methods in computed are not invoked after the first compilation (if the data does not change), that is, they are not executed until the data is updated.
- Method has no cache
- Whenever this method is used.
What is the difference between com Puted and Watch?
- In most cases, computed and watch are interchangeable,
- You can write async in watch,
- Watch is a little bit more complicated,
- Watch can achieve some simple functions
3. Is there a difference between watch and method?
- Watch is mainly used to monitor data changes
- Method is to write some general methods
Do not use watch if you can use computed
4. To summarize
Mounted hook () ¶ If the value of an attribute is not changed, it will be cached