Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

index.html 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <!DOCTYPE html>
  2. <html>
  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,user-scalable=no">
  7. <link rel="shortcut icon" href="<%= BASE_URL %>favicon.ico">
  8. <title>
  9. <%= VUE_APP_TITLE %>
  10. </title>
  11. </head>
  12. <body>
  13. <noscript>
  14. <strong>
  15. 请开启 JavaScript 功能来使用 <%= VUE_APP_TITLE %>。
  16. </strong>
  17. </noscript>
  18. <iframe id='IEIframe' style='display: none;' width="100%" height="100%" src="/static/ie.html"
  19. frameborder="0"></iframe>
  20. <div id="app"></div>
  21. </body>
  22. <script>
  23. function IEVersion() {
  24. var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
  25. var isIE =
  26. userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE<11浏览器
  27. if (isIE) {
  28. return true;
  29. } else {
  30. return false; //不是ie浏览器
  31. }
  32. }
  33. /* 如果是ie浏览器 */
  34. if (IEVersion()) {
  35. document.querySelector('#IEIframe').style.display = 'block'
  36. document.querySelector('#app').style.display = 'none'
  37. }
  38. // dataset 方法兼容 IE 浏览器。ie10及以下不支持dataset
  39. if (window.HTMLElement) {
  40. if (Object.getOwnPropertyNames(HTMLElement.prototype).indexOf('dataset') === -1) {
  41. Object.defineProperty(HTMLElement.prototype, 'dataset', {
  42. get: function () {
  43. var attributes = this.attributes // 获取节点的所有属性
  44. var name = []
  45. var value = [] // 定义两个数组保存属性名和属性值
  46. var obj = {} // 定义一个空对象
  47. for (var i = 0; i < attributes.length; i++) { // 遍历节点的所有属性
  48. if (attributes[i].nodeName.slice(0, 5) === 'data-') { // 如果属性名的前面5个字符符合"data-"
  49. // 取出属性名的"data-"的后面的字符串放入name数组中
  50. name.push(attributes[i].nodeName.slice(5));
  51. // 取出对应的属性值放入value数组中
  52. value.push(attributes[i].nodeValue);
  53. }
  54. }
  55. for (var j = 0; j < name.length; j++) { // 遍历name和value数组
  56. obj[name[j]] = value[j]; // 将属性名和属性值保存到obj中
  57. }
  58. return obj // 返回对象
  59. }
  60. })
  61. }
  62. }
  63. </script>
  64. </html>