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'
}
]
]
}
---> Console screenshot
---> Debugger screenshot
最佳答案
您的调试器屏幕截图显示错误来自 native-toast
包。该包的 GitHub 显示 unresolved issue ,其中使用了 for ... of
循环。 IE 不知道如何解释它,这是 Vue IE SCRIPT1004 错误(只是缺少分号)的常见原因。
您可以告诉 Vue CLI 转译整个 native-toast
依赖包,但默认情况下它不会执行此操作。在你的 vue.config.js
(不是 Babel)中:
module.exports = {
transpileDependencies: [
'native-toast'
]
}
(注意:transpileDependencies
是包名称 [或 RegExp] 的数组)
显然,在某些情况下,您可能还需要在 babel.config.js
中使用它(首先尝试不使用它):
module.exports = {
"presets": [
'@babel/preset-env'
],
}
引用:
关于javascript - IE11 上的 VueJS 错误 - SCRIPT1004 : Expected ';' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60798345/