试着在IE11中工作,我已经尝试了所有我在网上找到的东西。
我得到以下错误:
SCRIPT1002:语法错误 档案: vendor.js,行: 110874,列: 40
第110874行
args[0].replace(/%[a-zA-Z%]/g, match => {
if (match === '%%') {
return;
}
index++;
if (match === '%c') {
// We only are interested in the *last* %c
// (the user may have provided their own)
lastC = index;
}
});我已经做出了由角度指示的推荐的es5配置,并且我正在运行这些配置(https://angular.io/guide/deployment配置服务于ES5)。
我的polyfills.ts:
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
import 'classlist.js'; // Run `npm install --save classlist.js`.
/** IE10 and IE11 requires the following for the Reflect API. */
import 'core-js/es6/reflect';
import 'web-animations-js'; // Run `npm install --save web-animations-js`.
import 'zone.js/dist/zone'; // Included with Angular CLI.我的tsconfig.json:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "esnext",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
}
}我的tsconfig.es5.json:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "es5"
}
}我使用角形8和primeng;我运行的ng服务-配置es5;
Update:从我发现的情况来看,问题发生在我正在使用的socket-io客户机的依赖项上。稍微研究一下,问题似乎与socket客户端的调试和babel依赖有关。我真的需要在我的系统上使用套接字,所以我仍然在寻找解决方案。但如果我删除套接字-io-客户端,它将正常运行。
我通过以下两个主题找到了问题的根源:
https://github.com/visionmedia/debug/issues/729 https://github.com/babel/babel/issues/10707
发布于 2020-02-06 07:42:58
问题是箭头函数没有成功地转移。您是否按照这个答案中的步骤来支持IE11中的角8?如果您已经执行了这些步骤,并且问题仍然存在,那么可能是因为您使用了包含箭头函数的外部js库。
角CLI不传输Javascript代码。第三方代码应采用适当的格式。您应该使用该库的ES5版本使其与IE11兼容。
您还可以参考这条线,将lib设置为"es5"、"es6"、"dom"以查看它是否有效。如果不能工作,只需使用ES5库版本即可。
您可以使用exclude属性在webpack.config.js或babel.config.js中传输模块。我们可以改变这一点:
...
exclude: /node_modules/,
...这方面:
...
exclude: /node_modules\/(?!name-of-untranspiled-module)/,
...参考资料:如何处理包括es6在内的npm模块
https://stackoverflow.com/questions/60076978
复制相似问题