V-for ID绑定写法

<el-checkbox class="file" v-for="(domain, index) in requireFile" :key="index" :id="'mustCheck'+index" v-model="!domain.valid" readonly size="small">{{domain.name}}</el-checkbox>

书写时绑定循环可改变的值,主要如下写法
:id="‘mustCheck’+index"

index取的是当前v-for中的index序号

V-for el-checkbox中取值

Template

<el-checkbox class="filebt" v-for="(domain, index) in requireFile" :key="index" v-model="!domain.valid" readonly size="small">{{domain.name}}</el-checkbox>
</br>

Script

// 校验check必选checkBox选中值
getCheckBoxReturnValue :function(){

var ss = document.getElementsByClassName('filebt')
let callValue = true
for(var i = 0;i < ss.length;i ++) {
// 获取封装标签内的checkbox属性
let weather = ss[i].children[0].children[1].checked

if(weather == false){
callValue = false
}

}
return callValue;
},
Logo

前往低代码交流专区

更多推荐