watchPostEffect() Effect After Component Updates

Last updated: 2026-10-22

watchPostEffect() Effect After Component Updates

watchPostEffect() equals watchEffect with flush: 'post' — it runs after the component's DOM update, ideal for measuring the fresh DOM.

GroupReactivity: Core
KindAPI
ScopeComponent
Vue Version3.0+
SSR SupportYes

📝 Syntax

watchPostEffect(() => {
  console.log(el.value.offsetHeight)  // DOM already updated
})

⚙️ Arguments

effectThe effect function; options match watchEffect (no flush)

Returns:A stop function

▶ Example

Edit the code below and see the live result:

Output:

Shows the paragraph height; it follows font-size changes.

💡 Key Points

💡 Tip Plain watchEffect runs before DOM updates, so layout reads are stale — that is what this variant fixes.
ℹ️ Note watchEffect with { flush: 'post' } is identical.
⚠️ Warning Guard against null template refs before mount.
More case studies coming soon.

📚 Related Tutorials

❓ FAQ

Q One-line difference from watchEffect?
A Timing: watchEffect runs pre-update, watchPostEffect runs post-update.
Q When is it required?
A When reading element size, scroll position or focus after render.
Q Can nextTick replace it?
A For one-off reads nextTick works; for tracking changes continuously use watchPostEffect.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏