Razor Component Element-Scoped Keywords
Learn about element-scoped keywords supported by Razor components.
We'll cover the following...
In this lesson, we will cover the individual element-scoped Razor keywords supported by Razor components in Blazor. We have examples of their usage in the project setup below.
<Router AppAssembly="@typeof(App).Assembly"> <Found Context="routeData"> <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /> <FocusOnNavigate RouteData="@routeData" Selector="h1" /> </Found> <NotFound> <PageTitle>Not found</PageTitle> <LayoutView Layout="@typeof(MainLayout)"> <p role="alert">Sorry, there's nothing at this address.</p> </LayoutView> </NotFound> </Router>
Razor Components demonstration setup
Standard element-scope keywords
These keyword types apply to individual elements rather than a whole Razor component.
@attributes
Instead of specifying various attributes inside an HTML element, we can construct a dictionary of those and pass this dictionary into the HTML element by using the @attributes
directive on it. The dictionary must have string
as a key and object
as a value.
In ...