参考
https://www.cnblogs.com/stoneniqiu/p/5538109.html
https://blog.csdn.net/Szu_AKer/article/details/84928570
https://github.com/SFantasy/express-load-router
一、初始路由
// 入口文件app.js
var usersRouter = require('./routes/users');
app.use('/users', usersRouter);
// route.js
const express = require("express");
const router = express.Router();
router.get("/",function (req,res) {
res.send("test")
});
二、controller分离
// controller/home/home.js
module.exports.index = function (req, res) {
res.render('index', {
title: '哇,你好呀'
});
// res.send('嘿')
};
module.exports.oooo = function (req, res) {
res.render('oooo', {
title: 'ooo'
});