gpt4 book ai didi

html - MVC Razor View 中不呈现换行符

转载 作者:太空狗 更新时间:2023-10-29 13:37:16 25 4
gpt4 key购买 nike

我在 Controller 中生成了以下字符串值。

 cc.lstchat = "Reply the Number with your question... <br />";

foreach (clsChat item in lstchat)
{

cc.lstchat =cc.lstchat + item.DisplayNumber+". " + item.ChatItem+" <br/> ";
}

现在我试图在我的 View 中的 div 标记内显示上面的字符串值,但它不会呈现换行符。

<div id="divChat" style="width:400px;height:300px;border:double">
@Model.lstchat.ToString()
</div>

enter image description here

最佳答案

试试 @Html.Raw方法

@Html.Raw(Model.lstchat)

关于html - MVC Razor View 中不呈现换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19580754/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com