如何解决vue.js中文乱码问题
时间:2022-02-11 17:43
vue.js中文乱码是因为响应头默认编码类型为GBK,而文件为UFT-8类型导致的,其解决办法就是设置响应头编码类型为“charset=UTF-8”即可。 本教程操作环境:windows7系统、vue2.0版,DELL G3电脑。 【相关文章推荐:vue.js】 Vue2.0流式渲染中文乱码问题 在参照vue2.0中文官方文档学习服务端渲染之流式渲染时,因为响应头默认编码类型为GBK,而文件为UFT-8类型,所以出现了中文乱码问题。 解决办法:设置响应头编码类型即可 以上就是如何解决vue.js中文乱码问题的详细内容,更多请关注gxlsystem.com其它相关文章!response.setHeader("Content-type", "text/html;charset=UTF-8");
server.get('*',function(request,response){
response.setHeader("Content-type", "text/html;charset=UTF-8");
var stream = renderer.renderToStream(require('./assets/app')())
response.write(preAppHTML)
stream.on('data',function(chunk){
response.write(chunk)
})
stream.on('end',function(){
response.end(postAppHTML)
})
stream.on('error',function(error){
console.log(error)
return response.status(500).send('Server Error')
})
})