Passing a variable from node.js to html

后端 未结 9 1379
孤独总比滥情好
孤独总比滥情好 2020-11-27 18:12

I am trying to pass a variable from node.js to my HTML file.

app.get(\'/main\', function(req, res) {
  var name = \'hello\';
  res.render(__dirname + \"/view         


        
9条回答
  •  情话喂你
    2020-11-27 18:43

    If using Express it's not necessary to use a View Engine at all, use something like this:

    {{ name }}

    This works if you previously set your application to use HTML instead of any View Engine

提交回复
热议问题