Nodejs: Error: Cannot find module 'html'
var express = require('express'); var bodyParser = require('body-parser'); var app = express(); app.use(bodyParser.urlencoded({ extended: true })); app.set('port', (process.env.PORT || 5000)); app.use(express.static(__dirname + '/public')); app.set('views', __dirname + '/public'); app.engine('html', require('ejs').renderFile); app.set('view engine', 'html'); app.listen(app.get('port'), function() { });
来源:
https://www.manongdao.com/article-560519.html
模板循环数据:
<%for(var i=0; i<list.length; i++){ %> <div>111</div> <%= list[i].name%> <% } %> <% list.forEach((article) => { %> <div>222</div> <%= article.id%> <% }) %>