关于nodejs res.write返回中文乱码问题

关于nodejs res.write返回中文乱码问题

需要添加头部信息:'Content-Type': 'text/plain; charset=utf-8'
如下:

 res.writeHead(200, {
    
    'Content-Type': 'text/plain; charset=utf-8'});
 res.write(JSON.stringify({
    
    msg:data}),'utf8');

猜你喜欢

转载自blog.csdn.net/weixin_41481695/article/details/108250836