企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## 1.安装 ~~~ npm i ejs ~~~ >在html中写js,里面包裹的都是HTML语句 ## 2.起步 ~~~ <%= name %> ~~~ ~~~ //index.ejs <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <p>我的名字叫<%= name %></p> </body> </html> ~~~ ~~~ const ejs = require('ejs'); ejs.renderFile('./views/index.ejs',{name:"cheng"},function(err,data){ if(err){ console.log("编译失败") }else{ console.log(data); } }) ~~~