将带有html标记的纯文本转换为html字符串,并在Blazor中呈现
样本: 使用将带有html标记的纯文本转换为html字符串,并在Blazor中呈现,blazor,blazor-client-side,Blazor,Blazor Client Side,样本: 使用HttpUtility.HtmlEncode对其进行编码,并使用HttpUtility.HtmlDecode对其进行解码,但仍然没有任何用处。您需要 @(new HtmlString(s)) @((标记字符串)s) @代码 { 字符串s=“示例文本””; } 将在中呈现,Google无法找到标记字符串关键字。 @(new HtmlString(s)) <div >@((MarkupString)s)</div> @code { string s
HttpUtility.HtmlEncode
对其进行编码,并使用HttpUtility.HtmlDecode
对其进行解码,但仍然没有任何用处。您需要
@(new HtmlString(s))
@((标记字符串)s)
@代码
{
字符串s=“示例文本””;
}
将在
中呈现,Google无法找到标记字符串
关键字。
@(new HtmlString(s))
<div >@((MarkupString)s)</div>
@code
{
string s = "<p>Sample text</p>";
}