一、Iview Table 组件 多选框选中和禁选设置

10年积累的成都做网站、网站设计经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站制作后付款的网站建设流程,更有洪洞免费网站建设让你可以放心的选择与我们合作。
Table添加多选框
通过给 columns 数据设置一项,指定 type: 'selection' ,即可自动开启多选功能。
正确使用好以下事件,可以达到需要的效果:
给 data 项设置特殊 key _checked: true 可以默认选中当前项。
给 data 项设置特殊 key _disabled: true 可以禁止选择当前项。
例如:
for (var i = 0; i < res.data.list.length; i++) {
if (res.data.list[i].status === '1') {
res.data.list[i]._disabled = true // 设置复选框禁用
res.data.list[i]._checked= true // 设置复选框选中状态
}
}二、Iview Table 组件中点击Icon弹出Poptip的写法
1.图标禁用方式
{
title: '撤销',
key: 'operate',
width: 70,
fixed: 'right',
render: (h, params) => {
if (params.row.status === '1') { // 选中当前行信息
return h('div', [
h('div', [
h('Poptip', {
props: {
confirm: true,
title: '确定要撤销吗!'
},
on: {
'on-ok': () => {
this.cancelFunction(params.index)
}
}
}, [
h('Button', {
props: {
shape: 'circle',
icon: 'md-return-left'
}
})
])
])
])
} else {
return h('div', [
h('Button', {
props: {
shape: 'circle',
icon: 'md-return-left',
disabled: true // 禁用图标
}
})
])
}
}
},
2.图标禁用方式
{
title: '修改',
key: 'operate',
fixed: 'right',
width: 70,
textAlign: 'right',
render: (h, params) => {
return h('div', [
h('Button', {
props: {
shape: 'circle',
icon: 'ios-paper-plane',
disabled: params.row.status !== '0'
},
on: {
click: () => {
this.editFunction(params.index)
}
}
})
])
}
},
三、四元运算符 : 多个三元运算符 嵌套
var state = null; var display_state = (state == null ? "未用" : (state == true ? "在用" : "停用")) //display_state //"未用"
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持创新互联。