Example $nextTick() Method
The $nextTick() method waits for the DOM to update so that we can get the new, updated value from the DOM after re-render.
"Initial Message"
Comments to the code:
- Line 30: The 'message' data property is updated. This triggers a DOM update.
- Line 31: The DOM update have not actually happened yet at this point, so the value we get here is the old value.
- Line 32-34: $nextTick() waits for the DOM to update, so at this point we get the new text value from the updated p-tag.