标签:log const range run div orange lis ora bsp
const express =require(‘express‘) const path=require(‘path‘) const template=require(‘art-template‘) const app =express() //设置模板引 ,view文件 art后缀 app.set(‘view engine‘,‘art‘) //使用express兼容art-template模板引擎 app.engine(‘art‘,require(‘express-art-template‘)) app.get(‘/list‘,(req,res)=>{ let data={ title:‘水果‘, list:[‘apple‘,‘orange‘,‘banana‘] } //参数一,模板的名称;参数二渲染模板的数据 res.render(‘list‘,data); }) app.listen(3000,()=>{ console.log(‘running....‘) })
//在当前目录创建view文件夹
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <div>{{title}}</div> <div> <ul> {{each list}} <li>{{$value}}</li> {{/each}} </ul> </div> </body> </html>
,添加list.art文件
标签:log const range run div orange lis ora bsp
原文地址:https://www.cnblogs.com/hack-ing/p/12114647.html