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
What is a Viewport Mobile browsers place web pages...
Table of contents 1. Problem Background 2. What a...
Table of contents Preface sql_mode explained The ...
The default table name is base_data and the json ...
1. Achieve results 2. Data format returned by the...
<br /> English original: http://desktoppub.a...
Vue+js realizes the fade in and fade out of the v...
For many domestic advertisers, the creation and ev...
1. Some problems encountered I remember when we w...
The equal-width layout described in this article ...
This article was originally written by blogger We...
When using the font-family property in CSS to ref...
This article example shares the specific code for...
The installation tutorial of mysql 8.0.11 winx64 ...
The official source code of monaco-editor-vue is ...