IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    koa-mount、koa-static怎么用?

    dlyt发表于 2017-03-28 09:06:54
    love 0

    为什么只能渲染根目录

    能请求到
    app.use(convert(mount('/', serve(`${process.cwd()}/src/client`))))
    请求不到
    app.use(convert(mount('/aa', serve(`${process.cwd()}/src/client`))))
    错误提示
    TypeError: next is not a function
          at Object.serve (/Users/yangyss/Desktop/Cool/react-koa/node_modules/koa-static/index.js:47:14)
          at Object.<anonymous> (/Users/yangyss/Desktop/Cool/react-koa/node_modules/koa-mount/index.js:58:23)
          at Generator.next (<anonymous>)
          at onFulfilled (/Users/yangyss/Desktop/Cool/react-koa/node_modules/co/index.js:65:19)
          at /Users/yangyss/Desktop/Cool/react-koa/node_modules/co/index.js:54:5
          at Object.co (/Users/yangyss/Desktop/Cool/react-koa/node_modules/co/index.js:50:10)
          at converted (/Users/yangyss/Desktop/Cool/react-koa/node_modules/koa-convert/index.js:17:15)
          at dispatch (/Users/yangyss/Desktop/Cool/react-koa/node_modules/koa-compose/index.js:44:32)
          at next (/Users/yangyss/Desktop/Cool/react-koa/node_modules/koa-compose/index.js:45:18)
          at middleware (/Users/yangyss/Desktop/Cool/react-koa/node_modules/koa-webpack-middleware/node_modules/webpack-hot-middleware/middleware.js:26:48)
          at _callee$ (/Users/yangyss/Desktop/Cool/react-koa/node_modules/koa-webpack-middleware/lib/hotMiddleware.js:30:22)
          at tryCatch (/Users/yangyss/Desktop/Cool/react-koa/node_modules/regenerator-runtime/runtime.js:64:40)
          at Generator.invoke [as _invoke] (/Users/yangyss/Desktop/Cool/react-koa/node_modules/regenerator-runtime/runtime.js:299:22)
          at Generator.prototype.(anonymous function) [as next] (/Users/yangyss/Desktop/Cool/react-koa/node_modules/regenerator-runtime/runtime.js:116:21)
          at step (/Users/yangyss/Desktop/Cool/react-koa/node_modules/koa-webpack-middleware/lib/hotMiddleware.js:15:191)
          at /Users/yangyss/Desktop/Cool/react-koa/node_modules/koa-webpack-middleware/lib/hotMiddleware.js:15:437
    

    详细代码: https://github.com/dlyt/react-koa/blob/master/bin/server.js



沪ICP备19023445号-2号
友情链接