Events

app.on(‘mount’, callback(parent))

当子程序被挂载到父程序时,mount事件被发射。父程序对象作为参数,传递给回调方法。

  1. var admin = express();
  2. admin.on('mount', function(parent) {
  3. console.log('Admin Mounted');
  4. console.log(parent); // refers to the parent app
  5. });
  6. admin.get('/', function(req, res) {
  7. res.send('Admin Homepage');
  8. });
  9. app.use('/admin', admin);