Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vaadin 瓦丁路由器嵌套路由_Vaadin_Router_Web Component_Lit Element - Fatal编程技术网

Vaadin 瓦丁路由器嵌套路由

Vaadin 瓦丁路由器嵌套路由,vaadin,router,web-component,lit-element,Vaadin,Router,Web Component,Lit Element,我的应用程序是使用LitElement用JS编写的。我希望在我的应用程序中包含以下路由: /auth/login /auth/register 在我的app.js中,我将路由器配置为: router.setRoutes([ { path: '/auth', component: 'yp-auth-page', action: async () => await import('./modules/au

我的应用程序是使用LitElement用JS编写的。我希望在我的应用程序中包含以下路由:

/auth/login
/auth/register
在我的app.js中,我将路由器配置为:

router.setRoutes([
        {
            path: '/auth',
            component: 'yp-auth-page',
            action: async () => await import('./modules/auth/yp-auth-page'),
        },
    ]);
router.setRoutes([
        {
            path: '/login',
            component: 'yp-login-page',
        },
   ]); 
现在在yp auth页面中,我想做如下操作:

router.setRoutes([
        {
            path: '/auth',
            component: 'yp-auth-page',
            action: async () => await import('./modules/auth/yp-auth-page'),
        },
    ]);
router.setRoutes([
        {
            path: '/login',
            component: 'yp-login-page',
        },
   ]); 
但是,当我在我的子组件(yp auth page.js)中调用
router.setRoutes
时,我在App.js中得到一个错误:

未捕获(承诺中)错误:[Vaadin.Router]未找到页(/auth)


我刚刚开始学习Vaadin router,我找不到任何关于此错误的帖子,嵌套路由教程使用TS装饰器,因此我找不到一种方法来嵌套这样的路由。

您可以将它们添加到下面的childern中

import './modules/auth/yp-auth-page'
    router.setRoutes([
        {
            path: '/auth',
            component: 'yp-auth-page',
            children:[
                {
                   path: '/login',
                  component: 'yp-login-page',
                  action: () =>import('you login component')
               }
            ]
        },
    ]);
当您想要使用它时,只需从@vaadin/Router导入路由器即可 并使用
Router.go('/auth/login')