baozhengrui

导航

el-tree前面的复选框不能多选变成单选

<el-tree
    :data="dataTree"
    show-checkbox
    :default-expand-all="false"
    :check-strictly="true"
    node-key="label" 
    ref="tree"
    highlight-current
    accordion
    @node-click="handleNodeClick"
    @check="handleCheck"
    :props="defaultProps">
</el-tree>

handleNodeClick(data,node){ // 节点的点击事件
  console.log('tree', data);
  console.log('tree', node);
  window.localStorage.setItem("node", node);

  if (node.checked === true) { // 当树被选中时
  }
}


 handleCheck(nodes, resolve) {
    //nodes节点所对应的对象;resolve选中状态对象
    if (resolve.checkedKeys.length > 0) {
        this.$refs.tree.setCheckedKeys([nodes.label]);
    }
},

posted on 2024-08-15 08:41  芮艺  阅读(31)  评论(0编辑  收藏  举报