2023
2023
  • 发布:2023-10-08 08:40
  • 更新:2023-10-08 16:13
  • 阅读:344

uni-indexed-list 索引列表怎么实现单选功能

分类:uni-app

key值

2023-10-08 08:40 负责人:无 分享
已邀请:
喜欢技术的前端

喜欢技术的前端 - QQ---445849201

uni_modules/uni-indexed-list/components/uni-indexed-list/uni-indexed-list.vue
253行,改一下这个方法

onClick(e) {  
                let {  
                    idx,  
                    index  
                } = e  
                let obj = {}  
                for (let key in this.lists[idx].items[index]) {  
                    obj[key] = this.lists[idx].items[index][key]  
                }  
                let select = []  
                if (this.showSelect) {  
                    // this.lists[idx].items[index].checked = !this.lists[idx].items[index].checked  
                    this.lists.forEach((value, idx) => {  
                        value.items.forEach((item, index) => {  
                            item.checked = false  
                            if(e.idx == idx && e.index == index){  
                                item.checked = true  
                                let obj = {}  
                                for (let key in this.lists[idx].items[index]) {  
                                    obj[key] = this.lists[idx].items[index][key]  
                                }  
                                select.push(obj)  
                            }  
                            // if (item.checked) {  
                            //  let obj = {}  
                            //  for (let key in this.lists[idx].items[index]) {  
                            //      obj[key] = this.lists[idx].items[index][key]  
                            //  }  
                            //  select.push(obj)  
                            // }  
                        })  
                    })  
                }  
                this.$emit('click', {  
                    item: obj,  
                    select: select  
                })  
            }

要回复问题请先登录注册