如何显示数据库中的 html 标签

How to show html tag from database

我在数据库 (MongoDB) 中得到了这样的数据 "name": "My name","desc": "<p>some description</p>\r\n"

当我想在 ejs 文件代码中显示时 <h2><%= pd.name %></h2> <%= pd.desc %> 它会显示

My name <p>some description</p>

我试过检查它显示的元素.. "

一些描述

"如何将 str 转换为 html 标签

使用 <%- 而不是 <%=。例如,

<%- pd.desc %>

您还可以查看 tags in Ejs 的其他变体。