Make a summary every day, persistence is victory!

/** @date 2021-07-14 @description vuE-2. x About computed and watch */Copy the code

One (sequence)

I am often asked in interviews about the difference between computed and watch, but I always wonder why I compare the two together.

In my superficial understanding, computed is a variable based on the change of attributes in data, but the variable is changed based on other dependencies, while watch is a listener that monitors data changes and performs some operations after data changes

The connection between the two is based on Vue responsiveness to listen for data changes and do something about it, that’s my understanding

As for when to use computed and when to use watch, I think it is unnecessary. Obviously, I use computed when I want to make a new attribute based on some attributes in data, and I want to do some processing after a data change. For example, when calling a function and making a request, use watch; Am I going to do things like listen for property changes in computed, and then tune a bunch of functions? I must have done it in watch

May now doubt after reading the source code can have a deep understanding of it, later to solve the doubts.