正常在razor文件中,如果这样写:
<div>
@content
</div>
@code
{
string content = "<h1>hello world</h1>";
}
你将得到的是:
但是你的本意是要让它正常的渲染html,要怎么来实现呢?
<div>
@((MarkupString)(@content)
</div>
@code
{
string content = "<h1>hello world</h1>";
}
@((MarkupString)(@content) 这样就告诉blazor,要用html格式进行渲染。
这样就正常了。