Home>Article>Web Front-end> How to solve the problem of Chinese garbled characters in vue.js
vue.js Chinese garbled characters are caused by the default encoding type of the response header being GBK and the file being UFT-8. The solution is to set the response header encoding type to "charset=UTF-8" .
The operating environment of this tutorial: windows7 system, vue version 2.0, DELL G3 computer.
[Related article recommendations:vue.js]
Vue2.0 streaming rendering Chinese garbled problem
In reference When vue2.0 Chinese official document is learning server-side rendering and streaming rendering, because the default encoding type of the response header is GBK and the file is UFT-8, the Chinese garbled problem occurs.
Solution: Just set the response header encoding type
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') }) })
The above is the detailed content of How to solve the problem of Chinese garbled characters in vue.js. For more information, please follow other related articles on the PHP Chinese website!