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
Preface During my internship at the company, I us...
The two parameters innodb_flush_log_at_trx_commit...
Table of contents Download and install JDK Downlo...
environment Hostname IP address Serve Prometheus ...
Table of contents 1. Foreign key constraints What...
1. Add alternative text to your logo This has two...
This article mainly introduces the analysis of th...
1. Composite primary key The so-called composite ...
question Insufficient memory when docker installs...
This article example shares the specific code for...
MySQL allows you to create multiple indexes on th...
Table of contents 1. Overview of Docker consul 2....
First, we need a server with Docker installed. (I...
How to get the container startup command The cont...
Overview In the previous chapter, we learned abou...