<el-tree
ref="tree"
:data="treeData"
@check-change="dataCheckChange"
show-checkbox
:props="defaultProps"
:default-checked-keys="defaultcheckedkeys"
:default-expanded-keys="defaultexpandedkeys"
:check-strictly="true"
node-key="id"
></el-tree>
过度数组list
dataCheckChange(data, checked, node) {
let indexs = this.list.indexOf(data.id)
if (indexs < 0 && this.list.length === 1 && checked) {
this.
n
o
t
i
f
y
(
t
i
t
l
e
:
′
提
示
′
,
m
e
s
s
a
g
e
:
′
只
能
选
择
一
种
预
案
场
景
′
,
t
y
p
e
:
′
s
u
c
c
e
s
s
′
,
d
u
r
a
t
i
o
n
:
2000
)
t
h
i
s
.
notify({ title: '提示', message: '只能选择一种预案场景', type: 'success', duration: 2000 }) this.
notify(title:′提示′,message:′只能选择一种预案场景′,type:′success′,duration:2000)this.refs.tree.setChecked(data, false)
} else if (this.list.length === 0 && checked) {
// 发现数组为空, 且已选
// 防止数组有值 首先清空 ,在push
this.list = []
this.list.push(data.id)
} else if (indexs >= 0 && this.list.length === 1 && !checked) {
// 再次进行浮空操作
this.list = []
}
},
185




被折叠的 条评论
为什么被折叠?



