创建HREF以在大麻中的子页面
我的页面具有此指令@page“/sales/Reports”
,因此它以https://localhost/sales/sales/Reports/Reports
路由加载。
我想创建链接< a href =“”> report 1</a>
将导致子页面/sales>/sales/sales/Reports/{id}
- 例如https:// localhost/sales/sales/Reports/8c5b8c1c1c12b5-43ee-92c9-8d3bcb8644a4
,但不确定我在锚定的HREF中放了什么。当我简单地放置< a href =“@myguid”> report 1</a>
链接具有https:// localHost/localHost/8c5b8c1c1c12b5-43ee-92C9-92C9--92C9--92C9--92C9-- 8D3BCB8644A4
。我需要硬编码< a href =“ sales/reports/@myguid”> report 1</a>
还是有更明智的方法?
My page has this directive @page "/sales/reports"
so it loads at https://localhost/sales/reports
route.
I want to create link <a href="">Report 1</a>
that will lead to a sub-page /sales/reports/{id}
- for example https://localhost/sales/reports/8c5b8c1c-12b5-43ee-92c9-8d3bcb8644a4
but not sure what do I put in href of my anchor. When I simply put <a href="@myGuid">Report 1</a>
link has a form of https://localhost/8c5b8c1c-12b5-43ee-92c9-8d3bcb8644a4
. Do I need to hard-code <a href="sales/reports/@myGuid">Report 1</a>
or there is a smarter way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“子页面”一词并不是真正存在。
只有“页面”,它们有“路线”。有时,如您的示例,路线出现嵌套,但这并不是“子”。
您问题的答案是,是的,您需要包括通往“页面”的路线。
这不一定意味着页面本身中的硬编码。您可能会创建一个为您完成的帮助课。例如:
然后使用:
然后,如果您选择更改托管报告的路由,则只需要在助手类中更改它,并且网站中的所有锚元素都会自动选择该新路线。
Update
您还可以使用静态类来生成一个供您使用的模板,而不是@page Directive:
然后,而不是@page Directive,请使用:
The term 'subpage' does not really exist.
There are just 'pages' and they have 'routes'. Sometimes the route appears nested, as in your example, but this does not make it a 'subpage'.
The answer to your question is that, yes, you need to include the route to the 'page' you want to go to.
That doesn't necessarily mean hardcoding in the page itself. You might create a helper class that does that for you. For example:
Then use:
Then, if you choose to change the route where reports are hosted, you only need to change it in the helper class and all anchor elements in your site will automatically pick up that new route.
UPDATE
You can also use the static class to generate a template for you to use instead of @page directive:
And then, instead of @page directive, use: