template.h5.html 1.8 KB

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