Attribute check-strictly The official document provides the property check-strictly, which determines whether to strictly follow the practice of not associating parent and child items with each other when a check box is displayed. The default value is false. System character menu control issues The problem is that when controlling the system's character menu, the following conditions must be met: Requirements:1. check-strictly=false does not work According to the conditions that need to be met, it is obvious that check-strictly is set to false, so starting from the basis of the mutual relationship between check-strictly=false and the parent and child, the problem that needs to be solved is: 2. check-strictly=true, try it You can only try to set check-strictly to true, starting from check-strictly=true to strictly follow the principle that the parent and child are not related to each other. The problem that needs to be solved is: Solution code:1. el-tree tag attributes<el-tree ref="tree" :data="treeMenus" :props="multiProps" :show-checkbox="true" node-key="menuId" highlight-current :expand-on-click-node="false" :default-checked-keys="checkedId" :check-strictly="true" @check="clickDeal"> Node-key: The attribute used as a unique identifier for each tree node. The entire tree should be unique. A key value that uniquely identifies a node. According to the backend's response, for :props="multiProps", my configuration is: multiProps: { children: 'childs', label: 'name', disabled: this.isDisabled } The childrens field is identified as the child node and name is the node name. By default, children is identified as the child node and label is the node name. 2. Reassign the multiple-select tree when the el-tree component changesupdated () { // Set the default value for the multiple-select tree this.$refs.tree.setCheckedKeys(this.checkedId) }, checkedId is an array of checked nodes, without distinguishing between parent and child nodes. 3. Special processing when clicking on a check boxclickDeal (currentObj, treeStatus) { // Used for: When the parent and child nodes are strictly unrelated, the parent node notifies the child node to change synchronously when the parent node is checked, thus realizing a one-way association. let selected = treeStatus.checkedKeys.indexOf(currentObj.menuId) // -1 is not selected // selected if (selected !== -1) { // As long as the parent node is selected, the child node is selected this.selectedParent(currentObj) // Unify the processing of child nodes to the same check state this.uniteChildSame(currentObj, true) } else { // Unselected processing: All child nodes are unselected if (currentObj.childs.length !== 0) { this.uniteChildSame(currentObj, false) } } }, // Unify the processing of child nodes with the same check status uniteChildSame (treeList, isSelected) { this.$refs.tree.setChecked(treeList.menuId, isSelected) for (let i = 0; i < treeList.childs.length; i++) { this.uniteChildSame(treeList.childs[i], isSelected) } }, // Unified processing of parent nodes as selected selectedParent (currentObj) { let currentNode = this.$refs.tree.getNode(currentObj) if (currentNode.parent.key !== undefined) { this.$refs.tree.setChecked(currentNode.parent, true) this.selectedParent(currentNode.parent) } }, This is the end of this article about element's el-tree multiple-select tree (checkbox) parent-child node association or non-association. For more related element el-tree multiple-select tree non-association content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: How to quickly deploy Gitlab using Docker
>>: MySQL Failover Notes: Application-Aware Design Detailed Explanation
1. Delete file command: find the corresponding di...
To improve processing power and concurrency, Web ...
Detailed explanation of Linux LVM logical volume ...
1. Docker Network Mode When docker run creates a ...
MySQL 8 new features: My personal opinion on MySQ...
In the previous article, I introduced the detaile...
Introduction to Vue The current era of big front-...
Installation Script Ubuntu / CentOS There seems t...
Table of contents 1 The common rules for creating...
We often see a cool effect where the mouse hovers...
Table of contents 1 Test Cases 2 JS array dedupli...
1. Introduction to mysqlbackup mysqlbackup is the...
The RHEL/CentOS series of Linux operating systems...
Documentation: https://github.com/hilongjw/vue-la...
Use self:: or __CLASS__ to get a static reference...