Blazor布局类似于母版页的ASP Webforms概念,并且与ASP MVC中的Razor布局相同。
Web上几乎每个网站都有一个模板,该模板可在整个网站(页面顶部的品牌,底部的版权)或网站的特定子部分(例如管理员的特定菜单结构)中使用网站页面)。
这是通过创建一个用作当前页面内容周围的HTML包装程序的视图来实现的,该模板包含一个占位符,用于指示应在其中显示所包装页面内容的位置。
<h1>This is the start of my reusable layout</h1>
<div class="Content">
-- Some kind of indicator to specify the page's content will go here --
</div>
<footer>
This is the end of the layout
</footer>
然后,各个页面可以有选择地指定一个单独的布局,以将其内容包装在其中。
-- Some way of indicating which template to wrap this page's content in --
<h1>This is the content of your embedded page</h1>
生成的HTML看起来像这样
<h1>This is the start of my reusable layout</h1>
<div class="Content">
<h1>This is the content of your embedded page</h1>
</div>
<footer>
This is the end of the layout
</footer>