Go模板页面浏览器显示HTML源码问题

<!--
 * @Title: This is a  file for ……
 * @Author: JackieZheng
 * @Date: 2024-06-09 17:00:01
 * @LastEditTime: 2024-06-09 17:01:12
 * @LastEditors: Please set LastEditors
 * @Description:
 * @FilePath: \\GoCode\\templates\\index.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div>Hello {{.name}}</div>
  <div>{{.someStr}}</div>
</body>
</html>

以注释开始的页面会直接在浏览器输出HTML源码

其它情况则都显示正常:

1、无文件头注释 

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div>Hello {{.name}}</div>
  <div>{{.someStr}}</div>
</body>
</html>

2、无 “DOCTYPE”

<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div>Hello {{.name}}</div>
  <div>{{.someStr}}</div>
</body>
</html>

 3、文件头注释下移放其它位置

<!DOCTYPE html>
<!--
 * @Title: This is a  file for ……
 * @Author: JackieZheng
 * @Date: 2024-06-09 17:00:01
 * @LastEditTime: 2024-06-09 17:01:12
 * @LastEditors: Please set LastEditors
 * @Description:
 * @FilePath: \\GoCode\\templates\\index.html
-->
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div>Hello {{.name}}</div>
  <div>{{.someStr}}</div>
</body>
</html>

 

 

相关推荐

  1. jsp页面显示问题

    2024-06-10 10:02:03       52 阅读
  2. html】简单网页模板

    2024-06-10 10:02:03       31 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-06-10 10:02:03       168 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-06-10 10:02:03       185 阅读
  3. 在Django里面运行非项目文件

    2024-06-10 10:02:03       155 阅读
  4. Python语言-面向对象

    2024-06-10 10:02:03       169 阅读

热门阅读

  1. 2024前端面试准备4-Vue相关

    2024-06-10 10:02:03       32 阅读
  2. #10 解决Stable Diffusion常见问题和错误

    2024-06-10 10:02:03       36 阅读
  3. 006 CentOS 7.9 elasticsearch7.10.0安装及配置

    2024-06-10 10:02:03       33 阅读
  4. 1341. 电影评分

    2024-06-10 10:02:03       47 阅读
  5. 如何学好量子计算机技术的两种思路

    2024-06-10 10:02:03       38 阅读