【问题标题】:Return always the index.html with expressjs始终使用 expressjs 返回 index.html
【发布时间】:2013-08-12 20:23:36
【问题描述】:

如何为每个未定义的路由返回 index.hmtl 页面,除了 CSS 和 JavaScript 之类的静态文件?

【问题讨论】:

    标签: routing express


    【解决方案1】:

    好的,我必须添加这一行添加我的 app.js 的末尾

    app.use(function(req,res){
      res.render('index', {});
    });
    

    【讨论】:

      猜你喜欢
      • 2018-06-03
      • 1970-01-01
      • 1970-01-01
      • 2019-03-15
      • 1970-01-01
      • 1970-01-01
      • 2016-05-31
      • 2015-08-15
      • 2012-03-18
      相关资源
      最近更新 更多