方法1超过2的优势在于字符串解码的目的是什么?
方法1:
const { StringDecoder } = require('string_decoder')
const decoder = new StringDecoder('utf-8')
let body = ''
req.on('data', data => {
body += decoder.write(data)
})
方法2:
let body = ''
req.on('data', data => {
body += data.toString()
})