v-cloak Hide Un-compiled Template

Last updated: 2026-10-22

v-cloak Hide Un-compiled Template

v-cloak stays on the element until compilation finishes; paired with CSS it hides the raw template and prevents the {{ }} flash on first paint.

GroupDirectives
KindDirective
ScopeTemplate
Vue Version3.0+
SSR SupportYes

📝 Syntax

[v-cloak] { display: none; }

<div v-cloak>{{ msg }}</div>

⚙️ Arguments

expressionNo expression

Returns:Directive, no return value

▶ Example

Edit the code below and see the live result:

Output:

On slow networks the raw braces stay hidden until Vue mounts and the real text appears.

💡 Key Points

⚠️ Warning You must add the CSS rule [v-cloak]{display:none} yourself — the attribute carries no style.
ℹ️ Note Only needed with the full build and no bundler; compiled SFC output never flashes.
💡 Tip Vue removes the attribute after compilation, so the hiding rule stops applying.
More case studies coming soon.

📚 Related Tutorials

❓ FAQ

Q Why must I write the CSS myself?
A It is only a marker attribute — you declare [v-cloak]{display:none}.
Q Is it still needed in modern projects?
A Not with SFC bundling (no raw template); only full-build CDN pages need it.
Q Is the attribute removed after compile?
A Yes — Vue removes it on mount and the hiding rule stops applying.
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%

🙏 帮我们做得更好

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

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