节点EJS将数据传递到包含 [英] Node EJS passing data to an include
本文介绍了节点EJS将数据传递到包含的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当前,我正在弄乱Node和EJS模板。
但是我遇到了问题。我建立了一个由多个组件组成的页面,然后将这些组件称为索引页面,如下所示:
<%include components / header.ejs%>
我的问题是如何将数据(json)传递到特定的include? p>
我希望能够重用组件,但是要显示来自json的不同内容。
谢谢
解决方案
尝试:
<%-include( 'components / header.ejs',{data:'data'}); %>
Currently I'm messing around with Node and EJS templates.
However I have hit a problem. Im building up a page made up of multiple components and im calling these components into the index page like so:
<% include components/header.ejs %>
My question is how can I pass data (json) to that specific include?
I want to be able to reuse components however to show different content coming from json.
Thanks
解决方案
Try:
<%- include('components/header.ejs', {data: 'data'}); %>
这篇关于节点EJS将数据传递到包含的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文