<div class="popup"> <span @click="ChangeOrders(index)" >点击显示</span><!--index是循环数组的下标 -->
<div class="ordermsg popuptext" v-if="msgShow==index">
<span>选项一</span>
<span>选项二</span>
<span >选项三</span>
</div>
</div>
data(){
return{
msgShow:-1
}
}
methods:{
ChangeOrders(index){
this.msgShow = this.msgShow == index ? -2 : index;//判断条件,点击显示,再次点击隐藏
},
handleScroll(){//滑动隐藏条件
this.msgShow=‘-2‘
},
},
mounted(){
window.addEventListener("touchmove", this.handleScroll, true); //滑动隐藏不影响点击显示/隐藏
}