Vue learning (f) to calculate the difference between the properties and the listener properties and application scenarios

the difference

  • watch: monitoring is an attribute value, as long as the property value changes, it will trigger a callback function to perform a series of operations;

  • computed: monitoring is dependent on the value, which will be dependent on the value of the read cache in the case of directly multiplexing the same, only recomputing the change;

In addition, it is somewhat important difference is: Calculate property can not perform asynchronous tasks, calculations must be performed synchronously property. That calculation property can not request or perform asynchronous tasks to the server. If you encounter asynchronous tasks, they listen to the property. Watch computed properties may be detected.

reference

Detailed Vue calculated properties and the listener properties

Guess you like

Origin www.cnblogs.com/kunmomo/p/12499373.html