Vuejs2 IE11 with Vue Cli项目:脚本1002:语法错误
我的应用程序在Chrome/Firefox/Edge中运行良好,但IE11给了我一些问题。在本地主机上测试应用程序时,控制台中的IE11出现以下错误:Vuejs2 IE11 with Vue Cli项目:脚本1002:语法错误,vuejs2,internet-explorer-11,vue-cli-3,Vuejs2,Internet Explorer 11,Vue Cli 3,我的应用程序在Chrome/Firefox/Edge中运行良好,但IE11给了我一些问题。在本地主机上测试应用程序时,控制台中的IE11出现以下错误: SCRIPT1002: Syntax error app.js (49143, 1) 当我单击上述代码时,它会跳转到我代码的这一部分,作为可能的错误区域: "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webp
SCRIPT1002: Syntax error
app.js (49143, 1)
当我单击上述代码时,它会跳转到我代码的这一部分,作为可能的错误区域:
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Config; });
class Config { <---this is line 49143
constructor() {
this.config = {}
for(var i = 0; i < arguments.length; i++) {
Object.assign(this.config, arguments[i])
}
}
Babel.config.js
.browserslistrc
>1%
最后2个版本
不是ie上次我不得不处理此类错误时,我得出了以下解决方案:
babel.config.js
module.exports=函数(api){
常量配置={
“预设”:[
[“@babel/env”{
“目标”:{
“浏览器”:[
“最后4个版本”,
“IE 11”
]
}
}],
//“@babel/stage-0”
],
插件:[
//第0阶段
“@babel/插件建议函数绑定”,
//第一阶段
“@babel/plugin建议导出默认源”,
“@babel/plugin建议逻辑赋值运算符”,
[“@babel/plugin建议可选链接”,{“loose”:false}],
[“@babel/plugin建议管道操作符”,{“建议”:“最小”}],
[“@babel/plugin建议nullish合并运算符”,{“loose”:false}],
“@babel/plugin建议do表达式”,
//第二阶段
[“@babel/plugin提案装饰器”,{“legacy:true}],
“@babel/插件建议功能已发送”,
“@babel/plugin建议导出命名空间自”,
“@babel/plugin提案数字分隔符”,
“@babel/plugin建议抛出表达式”,
//第三阶段
“@babel/plugin语法动态导入”,
“@babel/plugin语法导入元”,
[“@babel/plugin建议类属性”,{“loose”:false}],
“@babel/plugin提案json字符串”,
[“transform-es2015-template-literals”{
//“松散”:没错,
“规格”:正确
}],
[“@babel/plugin转换运行时”{
“助手”:假,
“再生器”:正确
}]
],
};
返回配置;
};
ofc,所有这些babel插件都应该作为devdependency安装。您可以尝试将babel配置为点ES 5,如本线程的答案中所述。裁判:
{
"name": "test",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build --report --modern",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.18",
"@fortawesome/free-solid-svg-icons": "^5.8.2",
"@fortawesome/vue-fontawesome": "^0.1.6",
"animate.css": "^3.7.0",
"axios": "^0.18.0",
"bootstrap": "^4.2.1",
"bootstrap-vue": "^2.0.0-rc.20",
"jquery": "^3.4.1",
"jso": "^4.1.1",
"vue": "^2.6.10",
"vue-matomo": "^0.6.0",
"vue-popperjs": "^1.6.1",
"vue-router": "^3.0.6"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.7.0",
"@vue/cli-plugin-eslint": "^3.7.0",
"@vue/cli-service": "^3.7.0",
"@vue/eslint-config-prettier": "^4.0.1",
"babel-eslint": "^10.0.1",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.2.2",
"node-sass": "^4.12.0",
"sass-loader": "^7.1.0",
"vue-template-compiler": "^2.6.10"
}
}
module.exports = {
presets: ['@vue/app']
}
> 1%
last 2 versions
not ie <= 8