简体   繁体   English

Vue组件无法在IE中呈现

[英]vue components not rendering in IE

I create Vue.js components and they works just fine in Edge, Chrome, Firefox etc, but not rendering in IE11. 我创建了Vue.js组件,它们在Edge,Chrome,Firefox等中正常运行,但在IE11中无法呈现。 I use gulp to build a project and Babel to compile es6 to es5. 我使用gulp构建项目,并使用Babel将es6编译为es5。

.babelrc .babelrc

{
 "plugins": ["@babel/plugin-syntax-dynamic-import"],
  "presets": [
    ["vue", {"eventModifiers": false}],
    ["@babel/preset-env",{"useBuiltIns": "entry"}]]
}

May be i need others presets ? 我可能需要其他预设吗?

The @babel/present-env preset works in such a way that you need to define which browsers the build script should support. @ babel / present-env预设的工作方式需要您定义构建脚本应支持的浏览器。

You could create a browserlist that contains the exact browsers or browser support percentages you want to support - https://babeljs.io/docs/en/babel-preset-env#targets 你可以创建一个包含确切的浏览器或浏览器的支持百分比一个browserlist要支持- https://babeljs.io/docs/en/babel-preset-env#targets

For Modern browsers + IE11 (since the support is somewhere above 2%), you could use: 对于现代浏览器+ IE11(由于支持超过2%),您可以使用:

{
  "browserslist": [
    "> 2%"
  ]
}

As far as IE11 doesn't support IE11 you have to edit your 如果IE11不支持IE11,则必须编辑

babelrc (Babel 7) babelrc(通天塔7)

{
  "presets": [
    [
      "@vue/app",
      {
        "targets": {
          "ie": "11"
        }
      }
    ]
  ]
}

let me know if that helps. 让我知道是否有帮助。 If you are using Babel 6 then check Alen Genzić response. 如果您使用的是Babel 6,请检查AlenGenzić的回复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM