Preface: The Vue official website provides a total of 14 instructions, as follows:
Note : ☆ represents important and commonly used 1. v-text (v-instruction name = "variable", the variable needs data to provide a value)<p v-text="info"></p> <p v-text="'abc' + info"></p> <script> new Vue({ el: '#app', data: { info: 'a' } }) </script>
2. v-html (can parse html syntax) Sometimes in our The sample code is as follows: <p v-html="'<b>ok</b>'"></p> <p v-text="'<b>ok</b>'"></p> There is no difference between the two lines of code above except that they use different OK <b>ok</b>
3. v-once (render elements and components only once)Render elements and components only once. On subsequent re-renders, the element/component and all its children will be treated as static content and skipped. This can be used to optimize update performance. <input type="text" v-model="msg" v-once> // Render only once<p v-once>{{ msg }}</p> 4. v-cloak (prevent page flickering) This directive remains on the element until the associated instance finishes compiling. When used with 5. v-pre (understanding) Skips compilation of this element and its child elements. Can be used to display raw <div id="app"> <span v-pre>{{message}}</span> </div> <script> const app = new Vue({ el: "#app", data: { message: "hello" } }) </script> Normally, we will compile and display 6. v-bind6.1 Binding Properties If we want to bind the variables in our <div id="app"> <a v-bind:href="baidu" rel="external nofollow" >Baidu</a> <img :src="imgSrc" alt=""> </div> <script> const app = new Vue({ el: "#app", data: { message: "hello", baidu: "https://www.baidu.com", imgSrc: "upload/2022/web/pc_a91909218349e60ed8f6f6f226c30e5f.gif" } }) </script> We just need to add 6.2 Binding Class There are two ways to bind Implemented through objects: <div id="app"> <p v-bind:class="{color:isColor}">Hello, World</p> </div> <script> const app = new Vue({ el: "#app", data: { isColor: true } }) </script> <style> .color{ color: blue; } </style> The object method is like the code above This can be achieved by using an array: <div id="app"> <p :class="[classname1, classname2]">{{message}}</p> </div> <script> const app = new Vue({ el: "#app", data: { message: "hello", classname1: "pcolor", classname2: "fontSize" }, }) </script> <style> .pcolor{ color: red; } .fontSize{ font-size: 30px; } </style> When 6.3 Style BindingThere are also two ways to bind Style, one is to bind through an array, and the other is to bind through an object. Implemented through objects: <div id="app"> <p :style="{fontSize:'100px'}">{{message}}</p> </div> <script> const app = new Vue({ el: "#app", data: { message: "hello" } }) </script>
This can be achieved by using an array: <div id="app"> <p :style="[style1, style2]">{{message}}</p> </div> <script> const app = new Vue({ el: "#app", data: { message: "hello", style1: {background:'red'}, style2: {fontSize:'30px'}, } }) </script> This is the end of this article about learning Vue commands. For more relevant Vue command content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Use Visual Studio Code to connect to the MySql database and query
>>: HTML code example: detailed explanation of hyperlinks
<br />This is not only an era of information...
Recently I saw a barrage effect on B station call...
The effect to be achieved: When the mouse is plac...
When making a table page, sometimes the width set ...
This article shares with you a js special effect ...
ERROR 1290 (HY000) : The MySQL server is running ...
Preface: In MySQL, the system supports many chara...
I searched a lot online and found that many of th...
transform: scale(); Scaling will cause jitter in ...
1. Error error connecting to master 'x@xxxx:x...
Written in front In recent years, the live stream...
Table of contents Preface Create a Vite project R...
Use the vscode editor to create a vue template, s...
Table of contents Preface 1. How to cancel a requ...
Classification of color properties Any color can ...