Vue.js: Defer action to be executed after the DOM has updated
Published March 23, 2020 • 1 min read
Often you are faced with the situation that you want to access an element in the DOM that does not exist yet. For example, because it is still being created.
In jQuery in this case you will do:
$(document).on('click', '.selector', function() {
// do something
});
In Vue.js the global function Vue.nextTick() helps:
// ...
methods: {
doSomething() {
this.$nextTick(() => {
// do something
});
}
}
vus.js