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

Bug: layout中的transformComponent同一路由会执行两次 #5568

Open
5 tasks done
qq6559285 opened this issue Feb 20, 2025 · 0 comments
Open
5 tasks done

Bug: layout中的transformComponent同一路由会执行两次 #5568

qq6559285 opened this issue Feb 20, 2025 · 0 comments

Comments

@qq6559285
Copy link

qq6559285 commented Feb 20, 2025

Version

Vben Admin V5

Describe the bug?

layout中的transformComponent同一路由会执行两次,复现在官方DEMO中

Reproduction

content.vue

function transformComponent(
  component: VNode,
  route: RouteLocationNormalizedLoadedGeneric,
) {
  const routeName = route.name as string;
  // 如果组件没有 name,则直接返回
  if (!routeName) {
    return component;
  }

  const componentName = (component.type as any).name;

  // 已经设置过 name,则直接返回
  if (componentName) {
    return component;
  }

  // componentName 与 routeName 一致,则直接返回
  if (componentName === routeName) {
    return component;
  }

  // 设置 name
  component.type ||= {};
  (component.type as any).name = routeName;

  return component;
}

System Info

windows 10

Relevant log output

Validations

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

No branches or pull requests

1 participant