Skip to content

[Cascader] Cascader 无法使用懒加载,在现有demo 下如何实现lazy #2747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
synctimes163 opened this issue May 7, 2024 · 3 comments
Labels
demo 示例

Comments

@synctimes163
Copy link

这个功能解决了什么问题

[Cascader] Cascader 无法使用懒加载,在现有demo 下如何实现lazy

你建议的方案是什么

在现有demo 下实现lazy,提供demo

Copy link
Contributor

github-actions bot commented May 7, 2024

👋 @synctimes163,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@anlyyao anlyyao added the demo 示例 label May 8, 2024
@synctimes163
Copy link
Author

好了吗

@liuffff
Copy link
Collaborator

liuffff commented Mar 20, 2025

demo可以用以下示例

onPick(e) {
  console.log(e.detail);
  const { value, index } = e.detail;
  const { options } = this.properties;
  if (options[index] && value === options[index].value && options[index].children?.length === 0) {
    Toast({
    context: this,
    selector: '#t-toast',
    theme: 'loading',
    message: '加载中...',
    direction: 'column',
    duration: 500,
    preventScrollThrough: true,
    });
    // 模拟数据请求
    setTimeout(() => {
    options[0].children = [{ value: '110100', label: '北京市', children: [] }];
    this.setData({
    options,
    });
    hideToast({
    context: this,
    selector: '#t-toast',
    });
    }, 500);
 } else if (
  options[index]?.children[index] &&
  value === options[index]?.children[index].value &&
  options[index].children[index].children?.length === 0
  ) {
  Toast({
    context: this,
    selector: '#t-toast',
    theme: 'loading',
    message: '加载中...',
    direction: 'column',
    duration: 500,
    preventScrollThrough: true,
   });
// 模拟数据请求
  setTimeout(() => {
    options[0].children[0].children = [
    { value: '110101', label: '东城区' },
    { value: '110102', label: '西城区' },
    { value: '110105', label: '朝阳区' },
    { value: '110106', label: '丰台区' },
    { value: '110107', label: '石景山区' },
    { value: '110108', label: '海淀区' },
    { value: '110109', label: '门头沟区' },
    { value: '110111', label: '房山区' },
    { value: '110112', label: '通州区' },
    { value: '110113', label: '顺义区' },
    { value: '110114', label: '昌平区' },
    { value: '110115', label: '大兴区' },
    { value: '110116', label: '怀柔区' },
    { value: '110117', label: '平谷区' },
    { value: '110118', label: '密云区' },
    { value: '110119', label: '延庆区' },
    ];
    this.setData({
      options,
    });
    hideToast({
      context: this,
      selector: '#t-toast',
    });
  }, 500);
}

> },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
demo 示例
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants