我在Strapi上使用了一个所见即所得的富文本插件,添加一个媒体url返回以下字符串,然后我在React中使用dangerouslySetInnerHTML
将其转换为HTML。
<figure class="media">
<oembed url="https://www.youtube.com/watch?v=dQw4w9WgXcQ"></oembed>
</figure>
但这不会在浏览器中渲染YouTube视频。
我不知道如何去得到这个渲染。看看oEmbed,似乎在大多数情况下,它转换为一个iframe,但不知道如何做,当它作为一个字符串从HTTP请求响应返回。
1条答案
按热度按时间bfrts1fy1#
您可以使用所见即所得插件提供的
oembed plugin
将<oembed>
元素转换为<iframe>
元素。