Vaadin 瓦丁路由器嵌套路由
我的应用程序是使用LitElement用JS编写的。我希望在我的应用程序中包含以下路由: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
/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')