假设我有一个在线销售和订单处理应用程序。我有客户,发票,InvoiceItem。客户对其上一订单中的项目有疑问,并希望将链接发送给他们的销售代表。
Blazor如何处理URL应该是这样的情况...
https://myapp.com/customer/12345/Invoice/234/InvoiceItem/4
Blazor路由引擎是否可以做到这一点?
我已经读了很多博文,我的路由似乎止于:/page/{parameter},而我真的很喜欢/page/{parameter}/control/{parameter}/control/{parameter}/etc...
发布于 2020-11-16 23:25:52
至少在.NET Core3.1和.NET5中内置blazor,这是完全可能的。使用不同的参数名很重要,因为它们映射到剃须刀组件的[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;}
}https://stackoverflow.com/questions/62706921
复制相似问题