app实例对象
maty()方法执行后创建一个app对象,该对象继承自Koa Application。
set(name, value)
get(name)
filter(stageName, fn(ctx, next))
engine(extName, render(viewFilePath, data))
// 添加后缀为jade的模板渲染方法,例如home.jade文件
app.engine('jade', (filePath, data) => {
const fn = jade.compileFile(filePath, {
cache: false
});
const html = fn(data);
return html;
});mount([path,] koaApp)
Last updated