vue遍历按钮添加事件

HTML

<el-col :span="8" v-for="(item,index) in channelControl.channel" :key="item.id">
                      <el-card class="box-card">
                        <p class="inline borderp10"><span  class="Sname">cron:</span>
                          
                          <span v-show="!item.flagblur">{{item.cron}}</span>
                          <el-input v-show="item.flagblur" v-model="item.cron"></el-input>
                          <p
                            :class="{'el-icon-edit': !item.flagblur, 'el-icon-check': item.flagblur}"
                            @click="savesync(item,index,cron)"
                          ></p>
                         点击事件
                        </p>      
                        <p class="borderp10"><span  class="Sname">id:</span><span>{{item.id}}</span></p>
                        <!-- <p class="borderp10"><span  class="Sname">timeRange:</span><span>{{item.timeRange}}</span></p> -->
                        <p class="inline borderp10"><span  class="Sname">timeRange:</span>
                          
                          <span v-show="!item.flagrange">{{item.timeRange}}</span>
                          <el-input v-show="item.flagrange" v-model="item.timeRange"></el-input>
                          <p
                            :class="{'el-icon-edit': !item.flagrange, 'el-icon-check': item.flagrange}"
                            @click="flagrangeclick(item,index,timeRange)"
                          ></p>
                        </p> 
                        
               
                      </el-card>
                    </el-col>

js

data{
cron:false,
          timeRange:false,
}
savesync(item,index){
          if(!item.flagblur){
            this.channelControl.channel[index]['flagblur'] = true
          }else{
            this.channelControl.channel[index]['flagblur'] = false
          }
          this.channelControl.channel[index] = item
        },
        flagrangeclick(item,index){
          if(!item.flagrange){
            this.channelControl.channel[index]['flagrange'] = true
          }else{
            this.channelControl.channel[index]['flagrange'] = false
          }
          this.channelControl.channel[index] = item
        }

遍历增加事件

<div class="fl" v-for="childitem in item.property" :key="childitem.id">
                            <p class="titlename">{{childitem.name}}</p>
                            <span  v-show="!childitem.show">{{ childitem.value | capitalize}}</span>
                            <el-input v-show="childitem.show" v-model="childitem.value"></el-input>
                            <p
                              :class="{'el-icon-edit': !childitem.show, 'el-icon-check': childitem.show}"
                              @click="childitem.show = !childitem.show"
                            ></p>
                          </div>

js

let connectorArr=res.data.bridgeInfo.connectUpInfo.connector
                  let propertyArr=[]
                  for(var i=0;i<connectorArr.length;i++){//循环数组
                    propertyArr.push(connectorArr[i].property)
                  }
                  let newArr=[]
                  for(var i = 0; i < propertyArr.length;i++){
                      for(var j = 0; j < propertyArr[i].length;j++){
                          newArr.push(propertyArr[i][j])
                      }
                  }
                  // console.log("newArr",newArr)
                  for(var i=0;i<newArr.length;i++){//循环数组
                    // console.log("aaaaaa",newArr[i].encode)
                    if(newArr[i].encode==true){
                      newArr[i].value=base64.decode(newArr[i].value)
                    }
                  }
                  // console.log("newArr",newArr)
                  newArr.forEach(function(item){
                    _this.$set(item, 'show', false)
                  })

提交

 for (i = 0; i < saveArr.length; i++) { 
          delete  saveArr[i].show
        }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值