关于angular兼容ie9-11问题解决

angular 前端 · devil · 于 4年前 发布 · 1625 次阅读

由于部分项目需要兼容ie9-11,在用angular构建的项目当中,可以找到项目结构中的browserslist文件


......
> 0.5%
last 2 versions
Firefox ESR
not dead
not IE 9-11 For IE 9-11 support, remove 'not'.

可以看到需要支持ie9-11,要把not去掉

修改完browserslist文件之后,还需要修改tsconfig.json文件

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "module": "esnext",
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2015",
    "typeRoots": ["node_modules/@types"],
    "lib": ["es2018", "dom"]
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true
  }
}

tsconfig.json中的target属性改成es2015,在编译的时候会编译成两份。 之后会根据浏览器支持的版本,自动选择加载哪一份编译的文件

共收到 0 条回复
没有找到数据。
添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册