let count = 1
const props = {
label: 'name',
children: 'zones'
}
const loadNode = (node, resolve) => {
if (node.level === 0) {
return resolve([{ name: 'region1' }, { name: 'region2' }]);
}
if (node.level > 3) return resolve([]);
var hasChild;
if (node.data.name === 'region1') {
hasChild = true;
} else if (node.data.name === 'region2') {
hasChild = false;
} else {
hasChild = Math.random() > 0.5;
}
setTimeout(() => {
var data;
if (hasChild) {
data = [{
name: 'zone' + count++
}, {
name: 'zone' + count++
}];
} else {
data = [];
}
resolve(data);
}, 500);
};
<BeSelectTree
lazy
load={loadNode}
bind:value={value}
defaultProps={props}
/>