当前位置:网站首页>Why can't V-IF and V-for be used together
Why can't V-IF and V-for be used together
2022-04-23 05:25:00 【Python User】
v-if and v-for It can't be used together , Otherwise, it will cause a waste of performance !
reason : stay Vue2 in v-for Has a higher priority than v-if, If v-if The value of is false when ,v-for Still render according to priority , This creates a waste of resources , As shown below :
<template>
<div>
<!-- Can't be used at the same time , Waste of resources -->
<div v-for = "(it, i) in getData" v-key="i" v-if="flag">
</div>
</tempalte>
<script> export default {
data(){
return{
getData:[1,2,3], flag: false } } } </script>
Can be v-if Package in the outermost layer to solve :
<template>
<div>
<div v-if="flag">
<div v-for = "(it, i) in getData" v-key="i" ></div>
</div>
<!-- If you don't want to use it div label , You can also use template-->
<template v-if="flag">
<div v-for = "(it, i) in getData" v-key="i" ></div>
</template>
</div>
</tempalte>
<script> export default {
data(){
return{
getData:[1,2,3], flag: false } } } </script>
版权声明
本文为[Python User]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220544545497.html
边栏推荐
- My old programmer's perception of the dangers and opportunities of the times?
- 2021 年 25 大 DevOps 工具(下)
- Three 之 three.js (webgl)简单实现根据点绘制线/弧线(基于LineGeometry / Line2 / LineMaterial,绘制两点基于圆心的弧线段)
- Five key technologies to improve the devsecops framework
- Implementation of resnet-34 CNN with kears
- Source code analysis of how to use jump table in redis
- The prefix of static of egg can be modified, including boots
- Interpretation of common SQL statements
- (十一)vscode代码格式化配置
- selenium預先加載cookie的必要性
猜你喜欢
![Laravel [view]](/img/39/71db98d8832d9419bcc1097594d1b6.png)
Laravel [view]

工具在数字化转型中扮演了什么样的角色?

云计算与云原生 — OpenShift 的架构设计

数字化转型失败,有哪些原因?

Anti crawler (0): are you still climbing naked with selenium? You're being watched! Crack webdriver anti crawler

Project manager's thinking mode worth trying: project success equation

Cross domain CORS relationship~

selenium预先加载cookie的必要性

How to set the initial value of El input number to null

跨域CORS的情缘~
随机推荐
《2021年IT行业项目管理调查报告》重磅发布!
JVM memory and memory overflow exceptions (personal summary)
Laravel implements the Holy Grail model with template inheritance
数字化转型失败,有哪些原因?
Devops life cycle, all you want to know is here!
Solution of how to log in with mobile phone verification code in wireless network
What are the reasons for the failure of digital transformation?
The introduction of lean management needs to achieve these nine points in advance
Qingdao agile tour, coming!
Source code analysis of how to use jump table in redis
The annual transaction volume of the app store is US $1 million, and only 15% commission is paid. Small and medium-sized developers are very contradictory
Self incrementing sequence creation of MySQL
Kanban Quick Start Guide
Musk and twitter storm drama
Uniapp wechat sharing
phphphphphphphp
低代码和无代码的注意事项
Redis的基本知识
Parsing of string class intern() method
Let the LAN group use the remote device