el-tree半勾选回显问题

73 阅读1分钟

场景:租户授权、角色授权

:check-strictly="false"

this.$nextTick(() => {
    res.data.menuIds.map(item => { // 便利储存的keys
      this.$refs.tree.setChecked(item, true, false) // 设置选中
    })
})

// 获取选中的所有节点(包含半勾选的父节点)
const checked = [
  ...this.$refs.tree.getCheckedKeys(),
  ...this.$refs.tree.getHalfCheckedKeys(),
]

以上就是答案,不需要动态设置check-strictly一会是true一会是false 我在开源框架看到的全是这样乱写的。。。