koa 中間件 koa-art-template 的使用

例子html

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 worldapp

相關文章
相關標籤/搜索