<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # 如何獲取params express里經典用法 http://expressjs.com/en/4x/api.html#app.param ```javascript app.get('/user/:id', function (req, res, next) { console.log('although this matches'); next(); }); ``` 請求是 訪問http://127.0.0.1:3000/users/alfred 那么koa里如何使用呢? 關于路由 - express是自帶路由 - koa這貨沒有,所以,需要另外集成,koa-generator使用的是目前比較流行的koa-router(我喜歡它的是Express-style) https://github.com/alexmingoia/koa-router 好吧 routes/users.js ```javascript var router = require('koa-router')(); router.get('/:id', function *(next) { console.log(this.params); console.log(this.request.params); this.body = 'this a users response!'; }); module.exports = router; ``` 執行 ```shell npm run 2 ``` 訪問http://127.0.0.1:3000/users/alfred 日志 ``` <-- GET /users/alfred { id: 'alfred' } undefined GET /users/alfred - 28 ``` 首先肯定一點,this.params是可以取到params的,這點和express路由用法類似 但是注意的是 ```javascript this.request.params != this.params ``` 這說明params不是request上的方法,翻查源碼,確實是如此 https://github.com/alexmingoia/koa-router/blob/5.x/lib/router.js#L317
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看