
Title
Used to set page title
Add the Title
component to the web page and set the text
attribute
Demo
<b>Set the <code>Text</code> property</b>
@page "/titles"
<Title Text="I am the title" />
<p>Test page<p/>
There is no need to add the Title
component to the webpage, and the injection service TitleService
is called
Demo
Pay attention:
Text
attribute in App
or MainLayout
or Page
The Title
component of [Inject]
[NotNull]
private TitleService? TitleService { get; set; }
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
await TitleService.SetTitle("I am the title");
}
Call the TitleService
static method directly
Demo
Pay attention
Text
attribute in App
or MainLayout
or Page
The Title
component of protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
await TitleService.SetWebSiteTitle("I am the title");
}
B station related video link
交流群