首页 > 编程知识 正文

Element elswitch 循环数据使用方法,广泛使用的采集数据方法

时间:2023-05-04 05:46:23 阅读:193773 作者:805

结构层:

<div v-for="(item, index) in dataList" :key="index"> <el-row :gutter="20"> <el-col class="col-text" :span="14"> {{ item.text }} </el-col> <el-col :span="6"> <el-switch v-model="item.switchValue" active-color="#45cdff" inactive-color="#d6d6d6" @change="switchChange" > </el-switch> </el-col> </el-row></div>

dataList数据格式:

dataList: [ { text: 'xx工程师是否按约定时间上门', switchValue: true, type: '1001' }, { text: '是否主动出示上岗工作牌', switchValue: true, type: '1002' }, { text: 'xx完毕后是否逐项检查正常', switchValue: true, type: '1003' }, { text: 'xx完毕后是否清洁设备和现场', switchValue: true, type: '1004' }],

逻辑层:

// 评论switch switchChange(val) { let arr = JSON.parse(JSON.stringify(this.dataList)) console.log(arr, 'dataList') arr.filter((obj) => obj.switchValue !== val) let newArray = arr.filter((item) => { return item.switchValue }) console.log(newArray, '过滤后数据') let array = [] newArray.forEach((item) => { array.push(item.type + '#' + item.text + '#1') this.appraiseForm.aoIdDesResult = array.toString() }) console.log(array, '拼接数据') },

打印数据:

效果如下:

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。