例子

const Koa = require('koa');
const render =require('koa-art-template');
const path= require('path');
//创建服务器
const app=new Koa();
//渲染
render(app, {
  root: path.join(__dirname, 'view'),
  extname: '.html',
  debug: process.env.NODE_ENV !== 'production'
});
app.use(async function (ctx) {
  await ctx.render('index');
});
app.listen(8888,()=>{
    console.log('启动了')
});

  效果:

输出: hello world

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2021-07-14
猜你喜欢
  • 2021-07-26
  • 2022-12-23
  • 2021-04-07
  • 2022-12-23
  • 2022-01-22
  • 2022-12-23
相关资源
相似解决方案