vue 根據數組值刪除元素(存在刪除,不存在添加)


 
<template>
      <view v-for="(item, index) in dataList" :key="index">
         <view class="memberBox" @click="handleTouch(item, index)">{{index}}</view>
     </view>
</template>
  
<script>
export default {
  data(){
   dataList:[]
  }
  methods: {
    handleTouch(item,index){
    let arr = [1,2,3,4,5,6,7,8,9];
    let arr2 = [];
    let indexs = arr.findIndex((items) => items == 1);
    if(indexs==-1){
     arr2.push(item,id)
    }else{
    arr2.splice(arr2.indexOf(item.id),1)
    }
  }
 }
}
</script>

 


免責聲明!

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



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