How to tell whether an element is in an array in vue?

how to determine whether the id of tzlist exists in read_id? If the id:3 of tzlist exists in read_id, delete class= "net".

how to achieve this?

the newlyweds can"t thank the newlyweds for asking for help.

Nov.08,2021

is simple. Change the class of 11 lines of span to this: : class= "{net: read_id.indexOf (item.id) =-1}"


pass the value value to isInArray and return ture by traversing tzlist. If false is returned, it does not exist.

function isInArray (arr,value) {

    for(var i = 0; i < arr.length; iPP){
        if(value === arr[i]){
            return true;
        }
    }
    return false;
}


this.read_id.forEach((v)=>{
    let aa = this.tzlist.find(c=>c.id==v);
    if(aa){
        // class xxx.
    }
})

</span>
</div>
Menu