就是 当在浏览器地址中输入,http://localhost:3000/ 显示 index.html 的内容, 当 URL变成 http://localhost:3000/users 显示 user.html 的内容 我也使用 koa-router koa-static 这些中间件,但是 不知道怎么这个功能,
就是 当在浏览器地址中输入,http://localhost:3000/ 显示 index.html 的内容, 当 URL变成 http://localhost:3000/users 显示 user.html 的内容 我也使用 koa-router koa-static 这些中间件,但是 不知道怎么这个功能,
koa-router 不是这样玩的! 你这写法是 Express 的写法!具体怎么玩看这里!
如果你想向Express那样把路由分离到外部文件中(如‘routes’文件夹),写法如下