Skip to content
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

[icon] Cannot read properties of undefined (reading '0') #540

Closed
Likuichao opened this issue Oct 9, 2024 · 1 comment
Closed

[icon] Cannot read properties of undefined (reading '0') #540

Likuichao opened this issue Oct 9, 2024 · 1 comment

Comments

@Likuichao
Copy link

Likuichao commented Oct 9, 2024

tdesign 版本

1.3.10

重现链接

No response

重现步骤

本地测试没有问题,线上报错Cannot read properties of undefined (reading '0') ,导致左侧导航栏不展示;
线上重现错误:
1.利用tdesign初始化项目的代码:

  <t-submenu name={item.path} value={item.path} title={item.title} icon={renderIcon(item)}>
    {item.children && useRenderNav(item.children)}
  </t-submenu>
  
  const renderIcon = (item: any) => {
  if (typeof item.icon === 'string') {
    return () => item.icon && <t-icon name={item.icon}></t-icon>;
  }
  if (item.icon && typeof item.icon.render === 'function') {
    return () =>
      h(item.icon.render(), {
        class: 't-icon',
      });
  }
  return () => '';
};

2.通过打印输出,一级导航栏数据正常输出信息,然后报错Cannot read properties of undefined (reading '0') ,就没进入到二级导航栏,也没输出任何二级导航栏信息
怀疑是中的 icon={renderIcon(item)}错误导致
3.进一步定位看报错信息是item.icon.render执行报错

期望结果

正常展示左侧导航栏

实际结果

本地测试没有问题,线上报错Cannot read properties of undefined (reading '0') ,左侧导航栏不展示;

框架版本

Vue(3.2.37)

浏览器版本

Chrome(126.0.6478.127)

系统版本

MacOS(14.5)

Node版本

v16.14.1

补充说明

本地测试没有问题,线上才报错,原版本为 "tdesign-icons-vue-next": "0.1.7",
"tdesign-vue-next": "1.3.10",升级了tedesign版本"tdesign-icons-vue-next": "^0.2.2",
"tdesign-vue-next": "^1.8.0", 还是报这个错误;另外一个项目目前使用的是"tdesign-icons-vue-next": "^0.2.2",
"tdesign-vue-next": "^1.8.0"导航栏是正常展示;

@uyarn
Copy link
Collaborator

uyarn commented Oct 11, 2024

已企微沟通解答

@uyarn uyarn closed this as completed Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants