Home > Web Front-end > JS Tutorial > Detailed explanation of the calling sequence of functions in vue

Detailed explanation of the calling sequence of functions in vue

小云云
Release: 2018-03-19 10:51:36
Original
2360 people have browsed it

This article mainly shares an introduction to the calling sequence of functions in vue. It has a good reference value and I hope it will be helpful to everyone. Let’s follow the editor to take a look, I hope it can help everyone. Method is used to define methods. For example, if you @click="test", methods defines the method test.

created and ready are both the life cycle of vue components

created

Type: Function

Details:

Called synchronously after the instance is created. At this point the instance has finished parsing options, which means that: data bindings, computed properties, methods, watchers/event callbacks have been established. But DOM compilation has not started yet, $el does not exist yet.

ready

Type: Function

Details:

Compiling End and el are called after the first insertion of the document, such as after the first attached hook. Note that it must be triggered by Vue insertion (for example, it is called after vm.el inserts the document for the first time, such as after the first attached hook. Note that it must be triggered by Vue insertion (for example, vm.appendTo() and other methods or instructions update)) ready hook.

compted is a calculated attribute, such as


#

computed:{ 
b:function(){ 
return this.a+1 
} 
}
Copy after login

then the value of b is linked to a and is always equal to a. The value of +1 will change when the value of a is modified.

vue’s ajax library recommends using vue-resource. Generally, non-single-page applications can obtain data in ready. If it is a single-page application, it will be based on the route life. Cycle to obtain, such as


route: { 
data: function (transition) { 
//数据获取,修改data 
transition.next() 
} 
}
Copy after login

Related recommendations:

Explanation on calling recursive functions in php

Introduction to the calling method of anonymous functions in Javascript

Calling functions in JavaScript

The above is the detailed content of Detailed explanation of the calling sequence of functions in vue. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template