0
我刚开始使用jade和node。我将一个对象从节点传递给玉模板(parent.jade
),并将相同的玉文件(parent.jade
)传递给另一个文件(child.jade
)。它被描述如下:无法将服务器对象从一个玉文件传递到另一个玉文件
节点部分:
res.render('parent.jade', {data: mydata});
然后在parent.jade
我正确地接收数据:
doctype html
html
head
title parent
script(type="text/javascript" src="/resources/file_javascript.js").
var data_from_node = !{JSON.stringify(data)}; //getting the data in javascript file
body(data-title="parent")
div#header(class="wrap")
include header.pug
ul#list(class="nav nav-tabs")
footer(id="footer" class="footer")
include footer.pug
在child.pug
我包括父文件,但不能得到数据对象。我曾尝试一切,但没有什么是在这里工作我包括它以下列方式:
doctype html
html
head
title child.pug
body(data-title="child")
div(class="wrap")
include parent.pug //here I am including parent.pug getting the content right
div#mydiv(class="tab-content")
include table.pug
footer(id="footer" class="footer")
include footer.pug
script(type='text/javascript').
var data = !{JSON.stringify(data)}; //getting null here
script(type = "text/javascript", src = "/resources/file_javascript.js")
有没有办法从parent.pug
获得child.pug
的“数据对象”,因为我在child.pug
越来越空?