Problem a
Problem: Asynchronously successfully fetching data, but the data is not displayed on the page. Solution: To solve the problem by listening for the change of properties, listen for the change of data in watch.
Question 2
Problem: Multiple objects for the same component solution: Object creation must determine whether the object is created or not to prevent repeated rendering of data. This does not happen when you create objects in Mounted. This is mainly between components.
Question 3
Fault: Data on the route change page is not refreshed
Scenario: For example, article details, which depend on routing params parameters (ajax is written in the Created lifecycle), exit the page and enter another Article page will not run the lifecycle of the Created component because of lazy route loading, so the article data is still the data of the previous article. Solution: Watch monitors whether the route changes
Problem four
Problem: setTimeout/setInterval this points to a changed vue instance
Scene:
Workaround: Use arrow functions or
Problem five
Problem: setInterval route jumps continue to run without being destroyed
Scenario: Such as some bullet screen, revolving text, such as the need to call the right time, after the route jump, because the component has been destroyed, but setInterval has not been destroyed, it is still continuing the background call, the console keeps reporting errors, if the calculation is large, it cannot be cleared in time, will lead to serious page stuck.
Question 6
Problem: VUE route interception browser back implementation draft save similar requirements
Scenario: The entered information is not saved in case the user suddenly leaves. Usage: