search

Home  >  Q&A  >  body text

node.js - Express中的user.js是干嘛的?

使用express -e hello
生成了一些文件,user.js是干嘛的,为啥和index.js几乎一样?views里面有模板是怎样对应其他文件的?

高洛峰高洛峰2863 days ago949

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 15:22:30

    user.js contains routing rules, which can be seen from the following code of app.js. user.js and index.js are both routing rules, so they look similar.

    var routes = require('./routes/index');
    var users = require('./routes/users');
    
    app.use('/', routes);
    app.use('/users', users);

    Here are the study notes of express. Of course, I recommend the official documentation.

    reply
    0
  • Cancelreply