egg的脚手架生成的route.js如下
'use strict';
module.exports = app => {
const { router, controller } = app;
app.redirect('/', '/news');
router.get('/news', controller.news.list);
router.get('/news/item/:id', controller.news.detail);
router.get('/news/user/:id', controller.news.user);
};
其中
const { router, controller } = app
中的"app"对象是
module.exports = app
里的这个"app"用箭头函数简写传进来的。但是在整个代码中并没有看到
var app = require(egg.Applications)
的声明, 那么这个app对象到底是在什么时候申明的呢?谢谢!
回复 (2)
A
X
引用 atian25https://github.com/eggjs/egg core/blob/master/lib/loader/mixin/router.js L15 https://github.com/...
@atian25 非常感谢, 我刚刚没看cnode, 所以在知乎上又邀请了你一次, 抱歉打扰了
参与回复
登录后即可参与回复。登录