我已经将内容保存在下面的#descrition
中。
<div id="description" contenteditable="true"></div>
我的问题是,当我尝试显示它时,它不会显示为html格式,它显示的内容与使用<h1></h1>
和<br>
保存的数据相同。它仅显示纯文本。
<div id="description" contenteditable="true">{{ $description }}</div>
<h1>Descriptoin</h1> Doner, where I built and maintained banner adverts and microsites. <br> And...
有人知道如何正确显示吗?
您必须这样做,因为Blade {{}}语句是通过PHP的htmlspecialchars函数自动发送的,以防止XSS攻击。如果您不希望转义数据,则可以使用以下语法:
<div id="description" contenteditable="true">{!! $description !!}</div>
默认情况下,Laravel会转义特殊字符以防止XSS攻击。尝试使用此格式:
<div id="description" contenteditable="true">{!! $description !!}</div>