iview中多选框单选实现方法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | render: (h, params) => { return h('div', [ h('Checkbox', { props: { value: params.row.checkBox }, on: { 'on-change': e => { console.log(e) let self = this this.list.forEach(items => { // 先取消所有对象的勾选,checkBox设置为false this.$set(items, 'checkBox', false) self.isDisabled = true // 禁用按钮 }) if (e) { this.list[params.index].checkBox = e // 再将勾选的对象的checkBox设置为true self.isDisabled = false // 解除禁用按钮 } } } }) ]) } |
111
做啥子呢
list是什么呢?我用的默认的多选type:’selection’.
这个是我从项目列表直接复制出来的所以,可能就看着不完整,list是我请求的数据
为什么我的foreach会报错
Error in v-on handler: “TypeError: Cannot read property ‘forEach’ of undefined”
报错提示已经很清晰了哦