IE11 - SCRIPT1004 上的 VueJS 错误:预期';'



IE11-错误:SCRIPT1004:应为";">

嗨!我的网站适用于除IE之外的所有浏览器。我的babel.config.js文件:

module.exports = {
presets: [
['@vue/app', {
polyfills: [
'es.promise',
'es.symbol',
'es6.array.iterator'
]
}]
],
"plugins": [
"@babel/plugin-transform-shorthand-properties",
"@babel/plugin-proposal-object-rest-spread",
[
'component',
{
libraryName: 'element-ui',
styleLibraryName: 'theme-chalk'
}
]
]
}

--->控制台屏幕截图

--->调试器屏幕截图

调试器屏幕截图显示错误来自native-toast包。该包的GitHub显示了一个未解决的问题,其中使用了for ... of循环。IE不知道如何解释它,这是Vue IE SCRIPT1004错误(只是缺少分号(的常见原因。

您可以告诉Vue CLI转换整个native-toast依赖程序包,默认情况下它不会这样做。在你的vue.config.js(不是巴别塔(中:

module.exports = {
transpileDependencies: [
'native-toast'  
]
}

(注意:transpileDependencies是包名称的数组[或RegExp](

显然,在某些情况下,您可能也需要在babel.config.js中使用此功能(先尝试不使用它(:

module.exports = {
"presets": [
'@babel/preset-env'
],
}

参考:

Vue CLItranspileDependencies

Vue CLI polyfills指南

Vue ForumtranspileDependencies示例

最新更新