跳到主要内容
CNode

koa的controller要返回html内容该怎么做?

问答
Xxupeng086发布于 10 年前最后回复 10 年前
362290

生成的html,到页面上<%=str%> (ejs模版)展示后尖括号全部变成了 “& l t ; a ”,怎么防止被编码? 或者我就不该这么生成html?

查看回复

回复 (3)

X
xupeng086#110 年前

求解啊

J
Jerry-M#210 年前

这个koa没关系。返回原html应该<%- str %> , 我印象中是这样

W
wssgcg1213#310 年前

@xupeng086 你应该先去看看 ejs 的语法, <%= %> 的语法是会转义的 (Escaped output with <%= %> (escape function configurable)) https://npm.mirror.cqupt.edu.cn/package/ejs

参与回复

登录后即可参与回复。登录