1. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

这行代码可以解决编码问题(中文乱码)。

知识点

http-equiv 属性提供了 content 属性的信息/值的 HTTP 头。
http-equiv 属性可用于模拟一个 HTTP 响应头。

使用 http-equiv 已经不是规定 HTML 文档的字符集的唯一方式:

  • HTML 4.01: <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  • HTML5:<meta charset="UTF-8">