Home  >  Article  >  Web Front-end  >  Introduction to the calling sequence of functions in vue

Introduction to the calling sequence of functions in vue

亚连
亚连Original
2018-05-29 16:24:061538browse

Below I will share with you 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.

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 the vue component

created

Type: Function

Details:

In instance Called synchronously after creation. 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 
} 
}

Then the value of b is hooked to a, which is always equal to the value of a 1, and the value of a is modified. Sometimes it will change.

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 can be obtained according to the routing life cycle, such as

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

The above is what I compiled for everyone, I hope it will be helpful to everyone in the future.

Related articles:

E-mail address format verification in JavaScript

Introduction to time-sharing functions for javascript performance optimization

Detailed explanation of Vue custom dynamic component instances

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

Statement:
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