index.html 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <!DOCTYPE html>
  2. <html lang="">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width,initial-scale=1.0">
  7. <link rel="icon" href="<%= BASE_URL %>logo.png">
  8. <title><%= htmlWebpackPlugin.options.title %></title>
  9. <script>
  10. // 获取当前设备的宽度,设置rem的根字体大小
  11. let width = window.innerWidth
  12. width = width <= 1200 ? 1200 : width
  13. const htmlObj = document.getElementsByTagName('html')[0]
  14. htmlObj.style.fontSize = width / 56.47 + 'px'
  15. // 对resize事件进行浏览器兼容处理
  16. if(document.createEvent) {
  17. var event = document.createEvent("HTMLEvents");
  18. event.initEvent("resize", true, true);
  19. window.dispatchEvent(event);
  20. } else if(document.createEventObject) {
  21. window.fireEvent("onresize");
  22. }
  23. // 监听页面resize事件,重新设置rem的根字体大小
  24. window.onresize = function() {
  25. let width = window.innerWidth
  26. width = width <= 1200 ? 1200 : width
  27. htmlObj.style.fontSize = width / 56.47 + 'px'
  28. };
  29. </script>
  30. </head>
  31. <body>
  32. <noscript>
  33. <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
  34. </noscript>
  35. <div id="app"></div>
  36. <!-- built files will be auto injected -->
  37. </body>
  38. </html>