method
checkbox选择传给后台名称:
<li style=\"border-right: 1px solid #ECEDEE\" v-for=\"(item,index) in arr\" >
<input type=\"checkbox\" class=\"one\" @click.parent=\"one(item,index)\" v-model=\"item.state\">
<label for=\"one\">
<p class=\"name\">{{item.name}}</p>
</label>
</li>
one(val,index,e) {
val.state=!val.state
for(let i=0;i<this.arr.length;i++){
if(i===index){
if(this.arr[i].state){
this.axiosarr[index]=val
}else{this.axiosarr.splice(index,1)}}}}
checkbox通过请求后台数据渲染列表,然后根据选择状态反传状态。
<div class=\"ones\" v-for=\"(item, index) in aData\" :key=\"index\">
<input type=\"checkbox\":id=\"item.factoryId\":value=\"item.type\"@click=\"one(index,item)\">
<label :for=\"item.factoryId\">
<p class=\"name\">{{item.factoryName}}</p>
<p class=\"explain\">点击关联</p>
</label>
</div>
this.$axios({
}).then(res => {
console.log(res.data.data);
res.data.data.forEach(item => {
this.$set(item, \'type\', false)
this.aData.push(item)
})})
one(index,item) {
this.aData[index].type = !this.aData[index].type
this.axiosarr = []
this.aData.forEach(item => {
if (item.type) {
this.axiosarr.push(item.factoryId)}})
在遇到多个v-show/v-if控制,后台没有给标识的情况下,自己加索引。
<img v-show=\"creentIndex==index?!show:show\" :src=\"and+item.licensePath\" alt=\"\">
data里定义:creentIndex:-1,show:false
doclick(index){
if( this.creentIndex == index){
//一般控制的下标都不会超过1000
this.creentIndex = 1000
}else{
this.creentIndex = index}}
继续阅读与本文标签相同的文章
Cookie会话跟踪机制
-
数据库基础技术实践#网络安全基础技术实践课程
2026-05-18栏目: 教程
-
MySQL每组求最值的记录与每组前N条记录
2026-05-18栏目: 教程
-
OCP-052考试题库汇总(55)-CUUG内部解答版
2026-05-18栏目: 教程
-
【云栖活动】架构师、产品经理一对一座谈会/WORKSHOP-已截止
2026-05-18栏目: 教程
-
MySQL入门书籍和方法分享
2026-05-18栏目: 教程
