config/plugin.js
ejs: {
enable: true,
package: 'egg-view-ejs'
}
config/config.default.js
config.view = {
mapping: {'.html': 'ejs'} //左边写成.html后缀,会自动渲染.html文件
};
ejs应用
<% items.forEach(function(item){%>
<li><div style="width: auto !important;"><a href="javascript:void(0);"><div>
<span class="shengxiao"><%=item.zodiac%></span>
<i style="float: left;"><img src="<%=item.zodiac_img%>"></i>
<span class="shengxiao">[<%=item.punching%>]</span>
<span class="shuzi">
<%item.numbers.forEach(function(num){ %>
<b class="<%=num.wave_color%>"><%=num.number%></b>
<%})%>
</span></div></a></div></li>
<%})%>