当前位置:网站首页>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
边栏推荐
- Musk and twitter storm drama
- What are the most popular recruitment technical skills in 2022? You can't think of it
- Qingdao agile tour, coming!
- Implementation of resnet-34 CNN with kears
- Interview summary
- 7-4 is it too fat (10 points) PTA
- Data management of basic operation of mairadb database
- Devops life cycle, all you want to know is here!
- SQLyog的基本使用
- phphphphphphphp
猜你喜欢
随机推荐
Parsing of string class intern() method
Using PHP post temporary file mechanism to upload arbitrary files
如何在Word中添加漂亮的代码块 | 很全的方法整理和比较
[untitled] kimpei kdboxpro's cool running lantern coexists with beauty and strength
好的测试数据管理,到底要怎么做?
The prefix of static of egg can be modified, including boots
改进DevSecOps框架的 5 大关键技术
How to set the initial value of El input number to null
分支与循环语句
Laravel routing settings
Good test data management, in the end how to do?
FileReader API file operation
JS Array常见方法
mariadb数据库的主从复制
The source of anxiety of graduating college students looking for technology development jobs
CPT 104_TTL 09
引入精益管理方式,需要提前做到这九点
The 2021 IT industry project management survey report was released!
学习笔记:Unity CustomSRP-13-ColorGrading
2021-10-25









