将视图引擎更改为html会引起问题

时间:2018-10-09 11:30:54

标签: node.js routes viewengine

我有一个pug view engine项目,但现在我曾经使用html模板。我安装了consolidate & swig个模块,我的应用程序js从更改为:

app.set('views engine', 'pug')
app.use('/', require('./routes/index'));

收件人:

var cons = require('consolidate');
app.engine('html', cons.swig)
app.set('views engine', 'html')
app.use('/', require('./routes/index'));

但是在此之后,我的来自routes / index.js的代码不起作用(甚至不调用)。我究竟做错了什么?我可以从该文件中删除所有代码,并且仍然可以使用。来自route / index.js的代码

router.get('/', function(req, res, next) {
    //someLogic not working
    res.render('index', { data: data });
})
module.exports = router;

其他页面的路由逻辑效果很好。

0 个答案:

没有答案