2016-12-01 40 views
1

我使用anugular-CLI 1.0.0-beta.16具有polyfills.ts看起來像這樣:IE11問題角度CLI項目,polyfills是notworking

// This file includes polyfills needed by Angular 2 and is loaded before 
// the app. You can add your own extra polyfills to this file. 
import 'core-js/es6/symbol'; 
import 'core-js/es6/object'; 
import 'core-js/es6/function'; 
import 'core-js/es6/parse-int'; 
import 'core-js/es6/parse-float'; 
import 'core-js/es6/number'; 
import 'core-js/es6/math'; 
import 'core-js/es6/string'; 
import 'core-js/es6/date'; 
import 'core-js/es6/array'; 
import 'core-js/es6/regexp'; 
import 'core-js/es6/map'; 
import 'core-js/es6/set'; 
import 'core-js/es6/reflect'; 

import 'core-js/es7/reflect'; 
import 'zone.js/dist/zone'; 

但這pollyfills文件沒有工作IE11,它適用於Chrome,火狐,EDGE和我main.ts看起來是這樣的:

import "./polyfills.ts"; 
import {platformBrowserDynamic} from "@angular/platform-browser-dynamic"; 
import {enableProdMode} from "@angular/core"; 
import {environment} from "./environments/environment"; 
import {AppModule} from "./app/"; 

if (environment.production) { 
    enableProdMode(); 
} 

platformBrowserDynamic().bootstrapModule(AppModule); 

在IE11運行此脂肪箭頭表達錯誤產生顯示錯誤

SCRIPT1002: Syntax error 

對於在這個位置minifiedjs:

function arrayUnion(arr1, arr2) { 
    return arr1 
     .concat(arr2.filter(v => arr1.indexOf(v) === -1)); 
} 

,這是我tsconfig.json看起來像

{ 
    "compilerOptions": { 
    "declaration": false, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "lib": ["es6", "dom"], 
    "mapRoot": "./", 
    "module": "es6", 
    "moduleResolution": "node", 
    "outDir": "../dist/out-tsc", 
    "sourceMap": true, 
    "target": "es5", 
    "typeRoots": [ 
     "../node_modules/@types" 
    ] 
    } 
} 

@Cleton這是我tsconfig看起來像

+0

你能顯示你的tsconfig文件嗎? – Cleiton

+0

'{ 「compilerOptions」:{ 「聲明」:假, 「emitDecoratorMetadata」:真, 「experimentalDecorators」:真, 「LIB」:[ 「ES6」, 「DOM」], 「MAPROOT」: 「./」,「 」「module」:「 : 「ES5」, 「typeRoots」: 「../node_modules/@types」 ] }} ' 這@Cleiton是我tsconfig文件看起來像 –

+0

您tsconfig看起來不錯,但它是在你的項目的根源? – Cleiton

回答

1

你可能瞄準es6,它將箭頭函數編譯爲箭頭函數:

let fn =() => console.log("hey"); 

編譯爲:

let fn =() => console.log("hey"); 

但是,如果你的目標es5其編譯爲:

var fn = function() { return console.log("hey"); }; 

似乎IE11(或任何其他版本的探險家)do not yet support arrow functions
如果你想支持它,你將不得不針對es5或以下,因爲沒有箭頭函數的pollyfil。