当前位置:网站首页>6. common instructions (upper) v-cloak, v-once, v-pre
6. common instructions (upper) v-cloak, v-once, v-pre
2022-06-25 23:53:00 【Rice bowl on the other side】
v-cloak
v-cloak The function of instruction is vue End of association after sample rendering
The double brace interpolation syntax will display the precompiled text when encountering network delay
<body>
<div id="app">
<p>{
{a}}</p>
</div>
<script src="vue.js"></script>
<script> var vue=new Vue({
el:"#app", data:{
a:" I am the instruction of rendering v-cloak" }, }) </script>
</body>
Here it is , We can use v-cloak combination CSS Solve the problem of double brace rendering
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style> [v-cloak]{
display: none; } </style>
</head>
<body>
<div id="app">
<p v-cloak>{
{a}}</p>
</div>
<script src="vue.js"></script>
<script> var vue=new Vue({
el:"#app", data:{
a:" I am the instruction of rendering v-cloak" }, }) </script>
</body>
[v-cloak]css The selector selects html In the structure v-cloak Properties of , The element setting with this attribute display by none, because v-cloak This attribute is in vue After the instance of is loaded, the results are associated , So you need the hidden state of this element , The result is , Or blank , Or display the compiled text .
v-once
v-once The function of is to render the corresponding element only once , Data updates do not cause view updates , The goal is to optimize the page .
<body>
<div id="app">
<h2 v-once>{
{a}}</h2>
<button @click="add"> I'll add one </button>
<button @click="minus"> Point I minus one </button>
</div>
<script src="vue.js"></script>
<script> var vue=new Vue({
el:"#app", data:{
a:100 }, methods:{
add(){
this.a++ console.log(this.a) }, minus(){
this.a-- console.log(this.a) } } }) </script>
</body>
Usage scenarios usually have no dynamic element content , For example, some articles , Some fixed titles
v-pre
v-pre The function of attributes : Skip the compilation of this element , Directly display the text inside the element , The function is to skip a large number of nodes without instructions .
<h2 v-pre>{
{a}}</h2>
What the browser shows is that it has not been compiled h2 The text content in the element ,v-pre The advantage of property is to optimize the loading performance of the page
边栏推荐
- Record a simple question with ideas at the moment of brushing leetcode - Sword finger offer 09 Implementing queues with two stacks
- Raspberry pie sends hotspot for remote login
- CXF
- WordPress
- php性能优化
- 我的博客今天2岁167天了,我领取了先锋博主徽章_过路老熊_新浪博客
- SVN
- Talk about how to hot restart a spoole or PHP cli process
- php中使用Makefile编译protobuf协议文件
- Px4 multi computer simulation (gazebo)
猜你喜欢
随机推荐
How does excel translate Chinese words into English automatically? This formula teaches you
unsigned与signed之大白话
Database - mongodb
Uniapp -- the use of document collation and push of unipush
Analyse des cinq causes profondes de l'échec du développement de produits
proxy
[转载]RSLOGIX 5000实例教程
mysql5.7版本在配置文件my.ini[mysqld]加上skip-grant-tables后无法启动
mysql集群
权限设计=功能权限+数据权限
C# IO Stream 流(二)扩展类_封装器
发送邮件工具类
Kotlin null pointer bug
流数据
mysql版本升级+数据迁移
谈一谈PHP变量或参数的Copy On Write机制
Uniapp -- framework arrangement and analysis summary
c_ uart_ interface_ Example and offboard modes
STEP7主站与远程I/O组网_过路老熊_新浪博客
猕猴桃酵素的功效_过路老熊_新浪博客