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
Netease Kanyouxi official website (http://kanyoux...
Port Mapping Before the Docker container is start...
Record the installation and configuration method ...
Table of contents 1. Overview of MySQL Logical Ar...
Table of contents 1. Comparison of data before an...
Inside the style tag of the vue component, there ...
Install the required environment 1. gcc installat...
This article summarizes the implementation method...
Tomcat is an HTTP server that is the official ref...
Table of contents 1. Live broadcast effect 2. Ste...
01. Command Overview The paste command will merge...
1. MySQL installed via rpm package service mysqld...
This article shares the specific code of JavaScri...
This article uses examples to illustrate the simp...
Everyone knows that images on web pages are genera...