template.h5.html 1.6 KB

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