Summary HTML: element plus v-cloak CSS: [v-cloak]{display: none} process The mustache syntax will be displayed when the page is first loaded. usage In HTML, add <div id="app"> <nav>blabla</nav> <main v-cloak>{{text}}</main> </div> Set a style for v-cloak in CSS. This style is only applied before the vue instance is compiled. [v-cloak]{ display: none; } principle I haven't finished reading the source code, but I roughly understand the principle of First is the CSS selector. [target] selects "all elements with the target attribute.". You can click here to review selectors. Then [v-cloak] selects all elements with the After the instance is initialized, VueJS will remove the Vue-specific attributes. Before the instance is initialized, the HTML code for main written above actually looks like this: <main id="main" class="row" v-cloak=""> Then add CSS to set all elements with v-cloak In fact, it’s not just v-cloak. You can try using v-if. Use Source code Then I just read the source code, which is roughly this paragraph. Those who are interested can search and read it to understand it. if (isRealElement) { // mounting to a real element // check if this is server-rendered content and if we can perform // a successful hydration. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) { oldVnode.removeAttribute(SSR_ATTR); hydrating = true; } } This is the end of this article about how to prevent Vue from flashing in small projects. For more related content about Vue flashing in small projects, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! |
<<: Example of how to display a default image when an image does not exist in HTML
>>: CSS position fixed left and right double positioning implementation code
After entering the Docker container, if you exit ...
1. Function Introduction sed (Stream EDitor) is a...
HTML Paragraph Paragraphs are defined by the <...
environment Centos 6.6 MySQL 5.7 Install If the s...
Table of contents forEach() (ES6) method map() (E...
Table of contents 1. What is Proxy? 2. How to use...
The reason is simple: In HTML documents, multiple ...
There is a simple CSS method to realize the pop-u...
The use of Vue+ElementUI Tree is for your referen...
For historical reasons, MySQL replication is base...
Table of contents 1. Cross-domain filter CorsFilt...
Since my development environment is to install Ce...
The default ssh remote port in Linux is 22. Somet...
I have recently studied the hollowing effect. bac...
Before hiding: After hiding: CSS: Copy code The co...