javascript - Can node express use html for the front-end page? I really don't want to use jade
typecho
typecho 2017-07-03 11:41:37
0
7
805

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

typecho
typecho

Following the voice in heart.

reply all(7)
ringa_lee

You can use ejs Yeah

小葫芦

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.

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

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

学霸

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

伊谢尔伦

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

曾经蜡笔没有小新

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');
typecho

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)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template