【问题标题】:how to pass JS Object to json如何将 JS 对象传递给 json
【发布时间】:2015-10-06 08:17:56
【问题描述】:

我是玉石新手。

我有如下路线

var fortunes = ['a','b','c'];
app.get('/about', function(req, res){
    var temp = fortunes[Math.floor(Math.random()*Math.length)];
    res.render('about',{fortune:temp});
});

玉文件中如何使用幸运作为key?

我尝试过的 Jade 代码示例:

html
    head
        title = "about"
        body
            p1 This is fortune page
            blockquote #{fortune}

正在运行的 HandleBars 代码。

<h1>About fortune</h1>
<p>Your fortune for the day:</p>
 <blockquote>{{fortune}}</blockquote>

jade中如何直接使用对象键?

【问题讨论】:

    标签: node.js express pug


    【解决方案1】:
    html
        head
            title = "about"
            body
                p1 This is fortune page
                blockquote!= fortune
    

    别忘了配置你的应用使用jade引擎

    app.set('view engine', 'jade');
    

    【讨论】:

    • 您是否遇到任何错误...即使在开发者控制台@starkk92
    猜你喜欢
    • 2010-10-30
    • 2017-01-02
    • 1970-01-01
    • 1970-01-01
    • 2016-12-21
    • 2012-06-02
    • 2015-11-23
    • 2016-04-01
    • 1970-01-01
    相关资源
    最近更新 更多