如何解决node res.write 乱码问题
时间:2022-02-11 17:21
node res.write乱码的解决办法:1、设置头部信息为“Content-Type':'text/plain; charset=utf-8”;2、设置代码为“res.write(JSON.stringify({msg:data})”。 本文操作环境:Windows7系统,nodejs10.16.2版,Dell G3电脑。 如何解决node res.write 乱码问题? 关于nodejs res.write返回中文乱码问题 需要添加头部信息: 如下: 推荐学习:《node.js视频教程》 以上就是如何解决node res.write 乱码问题的详细内容,更多请关注gxlsystem.com其它相关文章!'Content-Type': 'text/plain; charset=utf-8'
res.writeHead(200, {'Content-Type': 'text/plain; charset=utf-8'});
res.write(JSON.stringify({msg:data}),'utf8');