![]() ![]() Extraneous markup doesn't appear in order to focus on the nested content provided by the three components involved: The following rendered HTML markup is produced by the preceding nested layout. Sorry, there's nothing at this LayoutComponentBase The following example sets a layout component named ErrorLayout for the MainLayout component's NotFound template (. You can use a LayoutView in any Razor component. To set a layout for arbitrary Razor template content, specify the layout with a LayoutView component. ![]() Apply a layout to arbitrary content ( LayoutView component) We recommend using the Router component to set the app's default layout because it's the most general and flexible approach for using layouts. Specifying the layout as a default layout in the Router component is a useful practice because you can override the layout on a per-component or per-folder basis, as described in the preceding sections of this article. Specifying a layout in _Imports.razor overrides a layout specified as the router's default app layout, which is described in the following section.įor more information on the Router component, see ASP.NET Core Blazor routing and navigation. The _Imports.razor file is similar to the _ViewImports.cshtml file for Razor views and pages but applied specifically to Razor component files. There's no need to repeatedly add DoctorWhoLayout to all of the Razor components (. Therefore, an _Imports.razor file containing DoctorWhoLayout ensures that all of the components in a folder use the DoctorWhoLayout component. The compiler includes the directives specified in the imports file in all of the Razor templates in the same folder and recursively in all of its subfolders. Set as the app's default layout, as described in the Apply a default layout to an app section later in this article.Įvery folder of an app can optionally contain a template file named _Imports.razor.Set by an directive imported from an _Imports component ( _Imports.razor), as described in the following Apply a layout to a folder of components section.Specifying the layout directly in a component overrides a default layout: ![]() ) come from the Episodes component.ĭoctor Who is a registered trademark of the BBC. ) come from the DoctorWhoLayout component.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |