template.h5.html 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <link rel="shortcut icon" type="image/x-icon" href="static/favicon.ico">
  7. <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  8. <title>
  9. <%= htmlWebpackPlugin.options.title %>
  10. </title>
  11. <script>
  12. document.addEventListener('DOMContentLoaded', function () {
  13. document.documentElement.style.fontSize = document.documentElement.clientWidth / 20 + 'px'
  14. })
  15. window.addEventListener(
  16. "error",
  17. function (e) {
  18. var jsLoadedErrorReload = window.sessionStorage.getItem(
  19. "jsLoadedErrorReload" // 跳转的标识,存入sessionStorage。用于不可控情况下,防止一直满足条件,触发死循环性的跳转页面
  20. );
  21. const fileReg = /\/js\/((chunk-vendors)|(app))\.[a-zA-Z0-9]+/;
  22. const filename = e.filename || e.target.src || "";
  23. if (jsLoadedErrorReload !== "true" && filename.match(fileReg)) {
  24. window.sessionStorage.setItem("jsLoadedErrorReload", true); // 满足条件则,存入标识
  25. let url = window.location.href;
  26. const timeStr = `timeStr=${Date.now()}`;
  27. url = /\?/.test(url) ? url + "&" + timeStr : url + "?" + timeStr;
  28. window.location.replace(url); // 跳转时添加了时间戳
  29. }
  30. },
  31. true
  32. );
  33. </script>
  34. <link rel="stylesheet" href="<%= BASE_URL %>static/index.css" />
  35. </head>
  36. <body>
  37. <noscript>
  38. <strong>本站点必须要开启JavaScript才能运行</strong>
  39. </noscript>
  40. <div id="app"></div>
  41. </body>
  42. </html>