var xm_one = xmSelectrender el #tree_one tips 请选择行业标签 empty 呀数据为空 filterable true searchTips 请在此搜索标签 paging false pageSize 10 radio false repeat false clickClose false
The error "Uncaught TypeError: Cannot read properties of undefined (reading '$el')" indicates that the "$el" property is undefined.
In the code provided, it seems that the issue occurs when trying to access the "$el" property of "xm_one.tree".
To fix this error, you can check if "xm_one.tree" is defined before accessing its "$el" property.
Here's an updated version of the code that includes the check:
if (xm_one.tree && xm_one.tree.$el) {
xm_one.tree.$el.on('clickCheck', function (data) {
var item = data.item;
var isParent = item.children.length > 0;
if (isParent) {
if (item.checked) {
xm_one.tree.setCheck(item.children, true);
} else {
xm_one.tree.setCheck(item.children, false);
}
} else {
var parent = item.parent;
if (item.checked) {
xm_one.tree.setCheck(item.parent, false);
} else {
var siblings = parent.children;
var uncheckedSiblings = siblings.filter(function (sibling) {
return !sibling.checked;
});
if (uncheckedSiblings.length === siblings.length - 1) {
xm_one.tree.setCheck(parent, true);
}
xm_one.tree.setCheck(item.parent, true);
}
}
});
}
By adding the check for "xm_one.tree" and "xm_one.tree.$el", the error should be resolved
原文地址: https://www.cveoy.top/t/topic/iyg5 著作权归作者所有。请勿转载和采集!