岁月_Ben 2019-09-02 11:42 采纳率: 33.3%
浏览 588

express用ejs模板传参问题

当我传参的用下面代码,得到的是一堆div什么什么的,但是是字符串
<%= include ('../compontents/everyInfor.html',{ data: data })%>
当我把=号改为-的时候<%- include ('../compontents/everyInfor.html',{ data: data })%>

出现

Could not find the include file "(&#39;../compontents/everyInfor.html&#39;,{"

什么问题,转义了,,,怎么搞

  • 写回答

1条回答 默认 最新

  • Json-Huang 2019-09-02 12:13
    关注

    <%-%>和<%=%>区别,前者会编译,后者不会编译,所以=会把html标签当成字符串一起输出,改成-报错是用法不太对把,一般include只包含文件,不需要加-如<% include ./footer.ejs %>

    评论

报告相同问题?