我为Express.js网站制作了一个主页,该主页有2个用于登录和注册的按钮。但是,当我单击按钮时,为什么不将我重定向到登录页面和注册页面?以下是我对主页的看法以及主页的路线。
查看主页:
extends layout
block content
h1 Welcome to Resume to Job!
style(type='text/css').
h1 {
margin-left: 250px;
text-align: center;
color: white;
font-size: 40px;
}
body
form(action= '/signup', name='signup' method='GET')
input(type='submit', value='Sign Up')
form(action='/login', name='login', method='GET')
input(type='submit', value='Log In')
style(type='text/css').
form {
margin-left: 610px;
color: DodgerBlue;
font-size: 40px;
padding-top:100px;
padding-bottom: 100px;
}
首页路由器:
var express = require('express');
var router = express.Router();
var sign_up_controller = require('../controllers/signUpController');
var login_controller = require('../controllers/logInController');
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index');
next();
}, function(req, res, next) {
res.redirect('/signup');
});
router.get('/signup', sign_up_controller.sign_up);
module.exports = router;