0% found this document useful (0 votes)
61 views2 pages

Vue - Nexttick ( (Callback, Context) ) : Arguments

Vue.nextTick() allows specifying a callback to be executed after the next DOM update cycle. It can be used after modifying data to wait for the DOM to update before executing additional code. It returns a Promise if no callback is provided. Vue.nextTick() defers execution of additional code until after the DOM updates in response to changes in component data.

Uploaded by

dorinadid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views2 pages

Vue - Nexttick ( (Callback, Context) ) : Arguments

Vue.nextTick() allows specifying a callback to be executed after the next DOM update cycle. It can be used after modifying data to wait for the DOM to update before executing additional code. It returns a Promise if no callback is provided. Vue.nextTick() defers execution of additional code until after the DOM updates in response to changes in component data.

Uploaded by

dorinadid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Vue.

nextTick( [callback, context] )


 Arguments:
o {Function} [callback]
o {Object} [context]
 Usage:
Defer the callback to be executed after the next DOM update cycle. Use it immediately after
you’ve changed some data to wait for the DOM update.
// modify data
vm.msg = 'Hello'
// DOM not updated yet
Vue.nextTick(function () {
// DOM updated
})

// usage as a promise (2.1.0+, see note below)


Vue.nextTick()
.then(function () {
// DOM updated
})
New in 2.1.0+: returns a Promise if no callback is provided and Promise is supported
in the execution environment. Please note that Vue does not come with a Promise
polyfill, so if you target browsers that don’t support Promises natively (looking at
you, IE), you will have to provide a polyfill yourself.
 See also: Async Update Queue
Vue.set( target, key, value )
 Arguments:
o {Object | Array} target
o {string | number} key
o {any} value
 Returns: the set value.
 Usage:
Set a property on an object. If the object is reactive, ensure the property is created as a
reactive property and trigger view updates. This is primarily used to get around the limitation
that Vue cannot detect property additions.
The target object cannot be a Vue instance, or the root data object of a Vue instance.
 See also: Reactivity in Depth
Vue.delete( target, key )
 Arguments:
o {Object | Array} target
o {string | number} key/index
Only in 2.2.0+: Also works with Array + index.
 Usage:
Delete a property on an object. If the object is reactive, ensure the deletion triggers view
updates. This is primarily used to get around the limitation that Vue cannot detect property
deletions, but you should rarely need to use it.
The target object cannot be a Vue instance, or the root data object of a Vue instance.
 See also: Reactivity in Depth
Vue.directive( id, [definition] )
 Arguments:
o {string} id
o {Function | Object} [definition]
 Usage:
Register or retrieve a global directive.
// register
Vue.directive('my-directive', {
bind: function () {},
inserted: function () {},
update: function () {},
componentUpdated: function () {},
unbind: function () {}
})

// register (function directive)


Vue.directive('my-directive', function () {
// this will be called as `bind` and `update`
})

// getter, return the directive definition if registered


var myDirective = Vue.directive('my-directive')

You might also like