MEAN 堆栈 - 将我的视图存储在 public 文件夹或服务器视图文件夹中有什么区别?

MEAN stack - What is the difference between storing my views in the public folder or the server views folder?

做前端的时候,我的HTML个文件都在public/app/views里。我注意到很多人也有服务器端的 views 文件夹,例如包含 .ejs 文件。那是为了让他们可以使用像 Jade 这样的模板引擎吗?如果我不使用模板引擎,我可以将所有视图保存在 public 文件夹中吗?

如果您使用 html 作为视图,您可以将它们存储在 public 文件夹中。在其他情况下(jade 或其他模板引擎),您必须将它们转换为 html 并复制到 public 文件夹,最好使用 Grunt 或 Gulp 来执行此操作。

如果不需要编译视图,可以将它们放在public文件夹中。

事实上,它可能会更快,因为您不必像

那样向服务器请求呈现的视图
router.get('/partials/:name', function (req, res){
   var name = req.params.name;
   res.render('partials/' + name);
});

希望对您有所帮助!