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

Redirect 引发整个页面重绘 #2259

Closed
afc163 opened this issue Sep 10, 2018 · 4 comments
Closed

Redirect 引发整个页面重绘 #2259

afc163 opened this issue Sep 10, 2018 · 4 comments
Assignees

Comments

@afc163
Copy link
Member

afc163 commented Sep 10, 2018

从 Menu 点击切换进入这个页面 https://preview.pro.ant.design/form/step-form/info

会导致 BasicLayout 的 componentDidMount 再次触发。

@ant-design-bot
Copy link

Translation of this issue:


Redirect Raises the entire page redraw

Click on the Menu to switch to this page https://preview.pro.ant.design/form/step-form/info

This will cause the ComponentDidMount of BasicLayout to fire again.

@siyu77
Copy link

siyu77 commented Sep 10, 2018

同样的问题, redirect 使 BasicLayout 组件重新构造了.

@sorrycc
Copy link
Contributor

sorrycc commented Sep 11, 2018

@yutingzhao1991 redirect 根据 bigfish 的传统,提到了页面最顶层,所以会 redirect 。

@yutingzhao1991
Copy link
Contributor

当时提到前面是有原因的,不然可能会另外的一个问题:

如果跳转放到后面那么比如类似下面的路由:

const routes = [
{
  path: '/admin',
  component: 'Admin',
},
{
  path: '/',
  component: 'BasicLayout',
  routes: [{
    path: '/redirect',
    redirect: '/admin',
  }]
}];

这种情况下如果访问 /redirect,那么 BasicLayout 会被先挂载,然后再跳转。

cc @zinkey 除了这个还有其他原因吗?

bigfish 之前我有提一个 issue: http://gitlab.alipay-inc.com/bigfish/bigfish/issues/198

sorrycc added a commit to umijs/umi that referenced this issue Sep 17, 2018
出于一些原因的考虑,我们在处理路由时把所有 redirect 声明提到路由最前面进行匹配,但这导致了一些问题,所以添加了这个配置项,禁用 redirect 上提。

比如:

1. ant-design/ant-design-pro#2259
2. 下面的路由配置,访问 `/console` 会访问到 `/console/overview`,因为 redirect 规则往前提了。

```
routes: [{
      path: '/',
      component: 'Index/App',
      indexRoute: { redirect: '/console' },
      routes: [
        {
          path: '/',
          component: '../components/layout/Default',
          routes: [
            {
              path: '/console',
              component: 'Index/Dashboard',
            },
            {
              path: '/:productName',
              indexRoute: { redirect: '/:productName/overview' },
              routes: [
                {
                  path: '/:productName/overview',
                  component: 'Index/product/Overview'
                },
              ]
            },

          ]
        }
      ],
  }],
```
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

5 participants