静态资源托管中间件
Koa并没有捆绑任何中间件,静态资源托管中间件需要独立安装,使用npm install koa-static安装静态资源托管中间件,之后使用与express使用方式一致了
const path = require("path");
const static = require('koa-static')
app.use(static(path.join(__dirname, "public"), {
index: "index.html", //默认首页
maxAge: 24 * 60 * 60 * 1000 //将静态文件缓存浏览器的时间,单位毫秒
}));

Comments NOTHING