Turn: blog.csdn.net/qq_22227087…

Life cycle:

  • Beforecreate: Generally used when loading events are added

  • Created: After loading ends, some initialization is done to implement self-execution of the function (the data is initialized, but the DOM structure is rendered, and the component is not loaded)

  • Beforemount: Before the component is created, but the operation is not started

  • Mounted: Specifies that a node is in the middle of launching a back-end request, retrieving data, and executing a routing hook.

  • Beforeupdate, updated: Before and after data updates

  • BeforeDestroy: Wants to delete a component while the current component is still there

  • Destroyed: Deletes the current component

Difference between Created and Mounted

  • Created: Called before a template is rendered to HTML, usually by initializing some property values and then rendering to a view.

  • Mounted: Specifies whether to perform operations on AN HTML DOM node after the template is initialized.

Mounted and methods

  • Mounted is a life cycle method. It is executed during the corresponding life cycle.

  • Methods are methods bound on Vue instance objects, which are used in the scope of the current Vue component. If not called, they will not be executed, only logic will be executed, and the return value is optional.

Difference between computed and watched

  • Computed is a calculation of attributes, which can also be understood as a method. The computed result does not fire if it does not change, and must return a value bound in the DOM to get the value. It can automatically get data changes.

  • The WATCHED property is a manually defined value that you want to listen for. You can define values multiple times for different data, which consumes performance and does not change automatically like computed.