This time I will show you how to use vue to determine the class of dom class, and what are the precautions for using vue to determine the class of dom. The following is a practical case, let's take a look.
vue clicks to add a class to the dom and then gets the dom containing the class<p class="chose-ck" v-for="(item,index2) in colors" :key="index2" ref="chosebox"> <p>{{item.name}}</p> <dt v-for="(item2,index) in item.childsCurGoods" :key="item2.id" :class="index==iac[index2]?'check':''" :id="item2.id" :data-chosename="item.name" :data-choseidname="item2.name" :data-chose="item.id" :data-id="item2.id" @click="chek(index2,index)" > {{item2.name}} </dt> </p>js chek(index2, index) { this.iac[index2] = index this.iac = this.iac.concat([]); this.checkchose() }, checkchose:function(){ var chose=this var chosedom=chose.$refs.chosebox console.log(chosedom) for (var i=0;i<chosedom.length;i++) { var children=chosedom[i].children for (var j=0;j<children.length;j++) { if(children[j].className=="check") { console.log(children[j]) } } } }
if(children[j].className=="check")
Node.js console output log file example analysis
How to use Vue to achieve drag and drop effects
The above is the detailed content of How to use vue to determine the class of dom. For more information, please follow other related articles on the PHP Chinese website!