代码之家  ›  专栏  ›  技术社区  ›  Pavel Strakhov

http.ServerRequest.prototype

  •  0
  • Pavel Strakhov  · 技术社区  · 15 年前

    我想将我自己的方法添加到http.ServerRequest对象。但是http.ServerRequest为空。我试过了 requset.prototype.testtest = function() { console.log('aaaaa'); }; 在服务器回调中。它回答“TypeError:无法设置未定义”的属性“testtest”。如何向ServerRequest对象添加方法?

    1 回复  |  直到 15 年前
        1
  •  0
  •   Ronny Wang    14 年前

    你可以用http.IncomingMessage.prototype.testtest=函数(){。。。}

    推荐文章