search

Home  >  Q&A  >  body text

javascript - Can node express use html for the front-end page? I really don’t want to use jade

Can node express use html for the front-end page? I really don’t want to use jade

typechotypecho2751 days ago847

reply all(7)I'll reply

  • ringa_lee

    ringa_lee2017-07-03 11:43:37

    You can use ejs Yeah

    reply
    0
  • 高洛峰

    高洛峰2017-07-03 11:43:37

    Absolutely. If you point directly to the html file, it is html. Of course, if you want to use the template function, it is best to use ejs.

    reply
    0
  • 巴扎黑

    巴扎黑2017-07-03 11:43:37

    app.engine('.html',ejs.__express);
    app.set('view engine', 'html');

    You can write it this way and render points to the html file

    reply
    0
  • 欧阳克

    欧阳克2017-07-03 11:43:37

    Of course, you can just put the html file in the static folder (usually public)

    app.use(express.static('public'));

    This sentence is to set up the static folder. It is set to public here, which means that all static files are found in the public directory

    See Hosting static files with Express for details

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-07-03 11:43:37

    Yes, write your html directly in the template file, and then render the written template file

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-07-03 11:43:37

    First install an ejs template engine
    Then just write this in the configuration file, which is the same as the third floor, and finally change the suffix of jade to html

    app.engine('html',ejs.__express); 
    app.set('view engine', 'html');

    reply
    0
  • typecho

    typecho2017-07-03 11:43:37

    When you say html, do you mean html files, or do you use a template similar to html syntax first?
    If you want to use html directly, just put the html file in a static directory, access the html directly, and then get the data through ajax
    If I want to use the template function, but I don’t want to use jade’s syntax, so I can use ejs (ejs syntax is very close to html)

    reply
    0
  • Cancelreply