express里如何将jade替换为html
这里我将贴出核心代码
app.js 文件如下
app.use(logger('dev')); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); app.use(cookieParser()); app.use(express.static(path.join(__dirname, 'public'))); app.use('/', routes); app.use('/users', users); app.use('/login', routes);//此处处理登陆
路由(routes)文件下的index文件
var express = require('express'); var router = express.Router(); /* GET home page. */ router.get('/', function(req, res, next) { //res.render('index', { title: 'Express' }); res.sendfile("./views/index.html"); }); router.get('/login', function (req, res, next) { res.render('login',{ title: '登录页面' }); // res.sendfile("./views/login.html"); });
视图文件(views)文件夹下的jade改为html
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <table> <h1><%=title%></h1> <tr> <td >用户名</td> <td><input type="text" name="name" value=""></td> </tr> <tr> <td >密码</td> <td><input type="text" name="pwd" value=""></td> </tr> </table> </body> </html>