Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE是如何兼容的? #1

Closed
Jvaeyhcd opened this issue Apr 24, 2019 · 6 comments
Closed

IE是如何兼容的? #1

Jvaeyhcd opened this issue Apr 24, 2019 · 6 comments

Comments

@Jvaeyhcd
Copy link

大神,请问您是如何兼容IE浏览器的,我的Nuxt.js项目在IE上各种问题,报SCRIPT1003的错误。

@anjoy8
Copy link
Owner

anjoy8 commented Apr 25, 2019

你好,我测试了下,我的项目是兼容 IE 9(+) 的,
我不知道你的浏览器版本是多少?
其实我也没有做什么兼容处理,Nuxt 官方的就是这样

@anjoy8
Copy link
Owner

anjoy8 commented Apr 25, 2019

你可以在 IE 浏览器里测试测试多个版本

@Jvaeyhcd
Copy link
Author

Jvaeyhcd commented Apr 25, 2019

@anjoy8 没有问题了,我解决了,在nuxt.js中引入:

...
module.exports = {
  mode: 'universal',

  /*
   ** Headers of the page
   */
  head: {
    ...
    script: [
      { src: 'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.2.5/polyfill.min.js' }
    ],
    ...
  },
  ...
  /*
   ** Build configuration
   */
  build: {
    // 为 JS 和 Vue 文件定制 babel 配置 -> https://nuxtjs.org/api/configuration-build/#analyze
    babel: {
      presets({ isServer }) {
        return [
          [
            require.resolve('@nuxtjs/babel-preset-app'),
            {
              targets: isServer
                ? { node: '10.4.0' }
                : { ie: 9 } 
            }
          ]
        ]
      }
    },
    ...
  }
}

通过如上的配置后,我的IE就能够正常打开了。

@anjoy8
Copy link
Owner

anjoy8 commented Apr 25, 2019

真棒的

@conquer123
Copy link

@anjoy8 没有问题了,我解决了,在nuxt.js中引入:

...
module.exports = {
  mode: 'universal',

  /*
   ** Headers of the page
   */
  head: {
    ...
    script: [
      { src: 'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.2.5/polyfill.min.js' }
    ],
    ...
  },
  ...
  /*
   ** Build configuration
   */
  build: {
    // 为 JS 和 Vue 文件定制 babel 配置 -> https://nuxtjs.org/api/configuration-build/#analyze
    babel: {
      presets({ isServer }) {
        return [
          [
            require.resolve('@nuxtjs/babel-preset-app'),
            {
              targets: isServer
                ? { node: '10.4.0' }
                : { ie: 9 } 
            }
          ]
        ]
      }
    },
    ...
  }
}

通过如上的配置后,我的IE就能够正常打开了。

请问大神,我按照你这个方法在IE下还是打不开,报错:
polyfill-eventsource added missing EventSource to window
SCRIPT1002: 语法错误
vendors.app.js, 行558 字符1

@yinzhenkun
Copy link

适配低版本IE 编译完的js文件 把use strict 全替换"" 亲测可用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants