【问题标题】:Does Blazor, or some NuGet package, support or extend the Routing for nested routes?Blazor 或某些 NuGet 包是否支持或扩展嵌套路由的路由?
【发布时间】:2020-10-23 16:15:05
【问题描述】:

假设我有一个在线销售和订单处理应用程序。我有客户、发票、发票项。客户对他们上次订单中的某件商品有疑问,并希望将链接发送给他们的销售代表。

Blazor 如何处理这种 URL 应该类似于...的情况

https://myapp.com/customer/12345/Invoice/234/InvoiceItem/4

Blazor 路由引擎可以做到这一点吗?

我已经阅读了多篇博客文章,并且路由似乎停止在: /page/{parameter} 而我真的很喜欢 /page/{parameter}/control/{parameter}/control/{parameter}/etc...

【问题讨论】:

    标签: blazor blazor-client-side blazor-webassembly


    【解决方案1】:

    这对于 blazor 中的内置功能是绝对可行的,至少在 .NET Core 3.1 和 .NET5 中是这样。 使用不同的参数名称很重要,因为它们映射到剃须刀组件[Parameter] 属性。

    对于您的示例,它将是:

    @page "/customer/{Customer}/invoice/{Invoice}/invoiceitem/{InvoiceItem}"
    
    <span>Customer: @Customer</span>
    <span>Invoice: @Invoice</span>
    <span>Item: @InvoiceItem</span>
    
    @code {
        [Parameter] public string Customer {get; set;}
        [Parameter] public string Invoice {get; set;}
        [Parameter] public string InvoiceItem {get; set;}
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-30
      • 1970-01-01
      • 2020-07-18
      • 2012-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多