繁体   English   中英

帮助在jade express中显示变量

[英]help with displaying a variable in jade express

我正在尝试使用res渲染加载一些变量:

res.render('blog_edit', {title: 'edit your blog', posts: "something"});

虽然标题加载精细帖子总是显示为未定义...以下是我试过的一些方法...

=posts

#{posts}

并作为一个javascript变量

script   
   document.write(posts)

他们都没有工作......你能帮忙吗? 提前致谢

尝试

  res.render('blog_edit', {locals:{title: 'edit your blog', posts: "something"}});

        #{locals.foo}

我今天使用的是最新版本(“express”:“4.11.2”,“jade”:“1.9.2”),这是适用于我的语法:

res.render('blog_edit', {title: 'edit your blog', posts: "something"});

在模板中:

#{locals.posts}

要么

#{posts}

这对我有用。

in JS
    res.render('index',  {email: req.params.email});

in Jade
   #{locals.email}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM