尝试让Angular在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;
}
});
我已经按照angular.io/guide/deployment的建议,配置了ES5的相关设置,并使用这些配置运行 (https://angular.io/guide/deployment "Configuring serves for 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"
}
}
我正在使用 angular 8 和 primeng; 并且我使用 ng serve -- configuration es5 运行;
更新: 根据我的发现,问题出现在我使用的 socket-io-client 的依赖关系上。经过一些研究,似乎问题与 socket-io-client 的 debug 和 babel 依赖关系有关。我确实需要在我的系统上使用 socket,所以我仍在寻找解决方案。但如果我移除 socket-io-client,它将会正常运行。
我通过以下两个主题找到了问题的源头:
"target": "es2015"
会生成 Internet Explorer 不支持的代码。 - Aluan Haddad