.NET 8 Blazor ssr 元标记内容在浏览器“查看页面源代码”中显示 utf-8 字符的哈希值

问题描述 投票:0回答:1
c# blazor meta-tags arabic .net-8.0
1个回答
0
投票

你可以先创建一个AppTitle.razor,代码如下:

<HeadContent>
    @(new MarkupString($"<meta name=\"keywords\" content=\"{Keywords}\" />"))
    @(new MarkupString($"<meta name=\"description\" content=\"{Description}\" />"))
    <title>@(new MarkupString($"{Title} - {AppTitle}"))</title>
</HeadContent>

@code {
    /// <summary>
    /// 
    /// </summary>
    [Parameter]
    public string AppTitle { get; set; } = "XXX";
    /// <summary>
    /// 
    /// </summary>
    public const string DefaultKeyWords = "XXX,XXX,XXX,";
    /// <summary>
    /// 
    /// </summary>
    [Parameter]
    public string Title { get; set; } = "XXX";
    /// <summary>
    /// 
    /// </summary>
    [Parameter]
    public string Keywords { get; set; } = DefaultKeyWords;
    /// <summary>
    /// 
    /// </summary>
    [Parameter]
    public string Description { get; set; } = DefaultKeyWords;
}

那么就可以这样使用:

<APPTitle Title="XXX" AppTitle="XXX" Keywords="XXX" Description="XXX"></APPTitle>
© www.soinside.com 2019 - 2024. All rights reserved.