undefinedfix
Sign in

Use the tree control of element to load lazily and always show loading

sq8vps edited in Sun, 02 Oct 2022

Use lazy: load = "asyncloadtree" to load data, or display loading all the time

clipboard.png

design sketch:

2 Replies
xtu
commented on Sun, 02 Oct 2022

asyncLoadtree

I guess it may be the following problem. Pay attention to the comments of the following code


loadNode(node, resolve) {
        if (node.level === 0) {
          return resolve([{ name: 'region' }]);
        }
        if (node.level > 1) return resolve([]);

        setTimeout(() => {
          const data = [{
            name: 'leaf',
            leaf: true
          }, {
            name: 'zone'
          }];

          resolve(data); // 这一个地方,可能是你问题的关键; 你是不是代码中没有 结束 promise
        }, 500);
      }

LiuGN
commented on Sun, 02 Oct 2022

First, resolve ( data ) , with data; Second, default - expand - All: whether to expand all nodes by default, because there is a problem with the data.