In vue, the background returned field is judged whether it is written into the template or not.

in some pages, there are many states, which are displayed according to the returned fields?

< div class= "div" Vmurf = "data.isOut="1"" > < / div >

this is my general way of writing, but if there are too many states, it will make it difficult to read, not thorough enough
another way is to write into the method, which method do you usually use?

Mar.24,2021

//  data  computed
//  
<div class="div" v-if="isShow(data.isOut)"></div>
methods:{
    isShow(val){
        //  
        // return  true or  false
    }
}

your problem is often encountered in the project. I usually use v-if to judge. If I write it into a method, I don't think the readability is much better. If you need to be familiar with this business, it should be easier to understand. You can't just add notes here and give an example.

// isStatus 0  1  2 
<div v-if="item.isStatus === 0"></div>
<div v-if="item.isStatus === 1"></div>
<div v-if="item.isStatus === 2"></div>

calculate properties with computed


if it's just a difference in text, you can write the state with an array or object

<div class="status">statusList[data.status]</div>
//0
statusList:['','','',...]
//
statusList:{
    0:'',
    1:'',
    2:'',
    ...
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3e1c2-4f04f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3e1c2-4f04f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?