search

Home  >  Q&A  >  body text

node.js - 为什么打data事件会触发多次直到服务器响应中的内容读完?

var data = "";
res.on('data', function (chunk) {
data += chunk;
}) .on("end", function () {

});
如果我不写这个事件监听,是不是nodejs内部还是会emit这个data事件多次?不是很理解这个事件的调用过程求科普

天蓬老师天蓬老师2827 days ago681

reply all(1)I'll reply

  • 黄舟

    黄舟2017-04-17 13:41:11

    Because it needs to set a fixed memory length to receive messages, it does not receive them all at once, but needs to be entered multiple times

    reply
    0
  • Cancelreply