描述标签上富文本字段的刀片视图

问题描述

我在laravel 7购物应用中使用voyager来描述所有产品。

我要输出产品说明的字段

@section('description',{!! $item->description !!} )

对于Facebook份额= og:description" content="{!! $item->description !!}">

当我在体内使用{!! $item->description !!}时,没问题。但是在标记中,输出始终会读取p标记,所有样式均会形成描述。

奇怪的是,它可以在localhost上找到,但不能在服务器上找到。我尝试了具有相同结果的各种解决方案组合。我觉得这里很快,或者只是不可能?

感谢我能提供的帮助

解决方法

尝试html_entity_decode()引用链接https://www.php.net/manual/en/function.html-entity-decode.php

{!! $item->description !!}

{!! html_entity_decode($item->description) !!} // it will render html 
,

如果您使用的是laravel 7/8,则可以创建刀片组件,然后可以简单地调用

<x-editor :content="$description></x-editor>

签出此laravel docs

,

尝试一下:

 {{strip_tags(trim($item->description)}}