You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
705 B
31 lines
705 B
4 months ago
|
// express官方微了art-template模板引擎更好的适用于express,在其基础上封装了press-art-template
|
||
|
|
||
|
const express = require("express")
|
||
|
|
||
|
const app = express()
|
||
|
|
||
|
app.locals.name={
|
||
|
name:"何琋",
|
||
|
sex:"男",
|
||
|
age:"22"
|
||
|
}
|
||
|
|
||
|
// 当渲染后缀会art的模板时,实用express-art-template
|
||
|
// 可以使用多种模板引擎
|
||
|
// 模板后缀,选用的模板引擎
|
||
|
app.engine("art",require("express-art-template"))
|
||
|
|
||
|
// 设置模板存放地址
|
||
|
app.set("views","templates")
|
||
|
|
||
|
// 设置模板默认后缀
|
||
|
app.set("view engine","art")
|
||
|
|
||
|
app.get("/",(req,res)=>{
|
||
|
res.render("index",{data:app.locals.name})
|
||
|
})
|
||
|
app.get("/pc",(req,res)=>{
|
||
|
res.render("pc.html",)
|
||
|
})
|
||
|
|
||
|
app.listen(80)
|