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

Route里不能嵌套Route? #121

Open
objHua opened this issue Apr 28, 2020 · 1 comment
Open

Route里不能嵌套Route? #121

objHua opened this issue Apr 28, 2020 · 1 comment

Comments

@objHua
Copy link

objHua commented Apr 28, 2020

问题
使用了HashRoute,在Route里面嵌套了两个子页面的Route,结果发现从/页面跳转子页面sub-table时match不到子页面。

期望:
sub-table等子页面也能正确匹配

代码:

const Home = () => {
    const userType: UserPermissionType = getPermissionType();
    return (
        <div className="root">
            <SystemHeader localStore={localStore} userStore={userStore} />
            <Route
                component={userType === UserPermissionType.Bussiness ? MainTablePage : HomePage}
                index
            />
            <Route
                component={SubTablePage}
                path="/sub-table"
                enterFilter={[initLang, loginCheck, checkPermission, getSetting]}
            />
            <Route
                component={AssignTable}
                path="/assign-business"
                enterFilter={[initLang, loginCheck, checkPermission]}
            />
        </div>
    );
};

const App = () => {
    return (
        <Provider
            userStore={userStore}
            localStore={localStore}
        >
            <LocaleProvider locale={localStore.currentLocal.muya}>
                <HashRouter>
                    <>
                        <Route
                            component={Home}
                            path="/"
                            enterFilter={[initLang, loginCheck, checkPermission, getSetting]}
                        />
                        <Route
                            component={NoPermission}
                            path="/no-permission"
                            enterFilter={[initLang]}
                        />
                        <Route component={LoginPage} path="/login" enterFilter={[initLang]} />
                    </>
                </HashRouter>
            </LocaleProvider>
        </Provider>
    );
};

ReactDom.render(<App />, document.querySelector('#root'));
@objHua
Copy link
Author

objHua commented Apr 28, 2020

也不算Route里面嵌套Route吧,严格来讲是Route里的组件添加Route,文档上说可以动态添加Route,但实际上添加的子页面并没有匹配到

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

1 participant