设置express ejs模板的后缀名html

如果使用jade或者ejs模板引擎的话 模板文件的格式为ejs或者jade ,有时候需要将后缀名修改为 html格式的。

app.set('view engine','ejs');
 app.engine('.html',require('ejs').__express);或者app.engine('html', require('ejs').renderFile);




同时route中的代码 也要加上后缀比如

exports.index = function(req, res){
res.render('index.html', { title: 'Express' });
};






原文地址:https://www.cnblogs.com/dubaokun/p/3446206.html