el-tree删除节点的勾选状态

el-tree删除节点的勾选状态
el-tree使用default-checked-keys属性,通过一个id数组赋值,设置树的复选框勾选状态。但删除选中状态的话,清空数组是无效的。数组的数据被删除无法直接反应在复选框取消勾选上。使用组件提供的this. r e f s . t r e e . s e t C h e c k e d K e y s ( [ ] ) ; 来 取 消 勾 选 t h i s . refs.tree.setCheckedKeys([]);来取消勾选 this. refs.tree.setCheckedKeys([]);this.nextTick() dom更新之后再执行回调

this.defaultcheckedtreenode = JSON.parse(JSON.stringify(this.defaultcheckedtreenode));
this.defaultcheckedtreenode.remove(config.id);//删除相应父级的勾选状态
this.$nextTick(function() {//取消勾选状态的方法需要配合setCheckedKeys使用。直接改变数组数据无法取消勾选状态
	this.$refs.tree.setCheckedKeys(this.defaultcheckedtreenode,true);
})
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值