如何在vaadin路由器中使用参数制作动态路由器 [英] how to make a dynamic router with parameters in vaadin router

查看:36
本文介绍了如何在vaadin路由器中使用参数制作动态路由器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下地址 http://localhost:3000/script?company=1

I have the following address http://localhost:3000/script?company=1

如何在这个地址显示需要的组件?我的代码怎么了?

How to display the required component at this address? What's wrog with me code?

   {
            path: '/script?company=:companyId',
            component: 'script-page',
            action: (context, commands) => this.protectedRouter(context, commands)
        },

推荐答案

我觉得问题是/script?company=:companyId 格式不对.正确的格式应该如下(假设companyId是必填参数)

I think the problem is that the format /script?company=:companyId is wrong. The correct format should be like the following (assuming the companyId is required parameter)

{
    path: '/script/:companyId',
    component: 'script-page',
    action: (context, commands) => this.protectedRouter(context, commands)
},

请参阅 Vaadin (Fusion) 路由器文档了解更多详情以及如何使用可选和通配符 URL 参数的示例.

See the Vaadin (Fusion) Router documentation for more details and examples how to use optional and wildcard URL parameters.

这篇关于如何在vaadin路由器中使用参数制作动态路由器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆