在浏览器访问html页面的时候出现中文乱码。
1、html没有设置<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
此行代码的作用是浏览器打开该文件的编码方式。
<html> <head> <!-- <meta http-equiv="content-type" content="text/html; charset=UTF-8"> --> <title>小游戏</title> </head> <body> ............中文显示 </body> </html>
测试结果:显示中文乱码
设置<meta http-equiv="content-type" content="text/html; charset=UTF-8"> 后浏览器显示正常