vue實現移動端滑動隱藏內容


<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);    //滑動隱藏不影響點擊顯示/隱藏        
   }
 
 
 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM