IE11 上的 VueJS 错误 - SCRIPT1004:应为“;”
VueJS error on IE11 - SCRIPT1004: Expected ';'
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'
],
}
参考:
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'
],
}
参考: