2016-09-23 50 views
0

我有一個node/express/angular 2應用程序。在桌面Safari瀏覽器/ Chrome瀏覽器中加載應用程序工作得很好。沒有錯誤。但是,如果我再嘗試將其引導進入的iOS的Safari移動瀏覽器,我收到:Angular 2,iOS safari錯誤:eval @ [native code]

Error: [email protected][native code] 
[email protected]://localhost:3001/js/vendor/zone.js/dist/zone.js:203:33 
[email protected]://localhost:3001/js/vendor/zone.js/dist/zone.js:96:49 
http://localhost:3001/js/vendor/zone.js/dist/zone.js:462:60 
[email protected]://localhost:3001/js/vendor/zone.js/dist/zone.js:236:42 
[email protected]://localhost:3001/js/vendor/zone.js/dist/zone.js:136:57 
[email protected]://localhost:3001/js/vendor/zone.js/dist/zone.js:368:42 
[email protected]://localhost:3001/js/vendor/es6-shim/es6-shim.min.js:11:1440 
http://localhost:3001/js/vendor/es6-shim/es6-shim.min.js:11:1370 
[email protected][native code] 
Evaluating http://localhost:3001/js/app/boot.js 
Error loading http://localhost:3001/js/app/boot.js 

不太清楚,如果這是一些加載問題?還是兼容性問題? index.hbs

<!doctype html> 
<html lang="en"> 
<head> 
<base href="/"> 
<meta charset="UTF-8"> 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"> 
<link rel='stylesheet' href='/stylesheets/style.css'/> 
<link rel='stylesheet' href='/stylesheets/login-styles.css'/> 
<link rel='stylesheet' href='/stylesheets/messenger-list-styles.css'/> 

<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css"> 
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=Intl.~locale.en"></script> 

<script src="js/vendor/es6-shim/es6-shim.min.js"></script> 
<script src="js/vendor/zone.js/dist/zone.js"></script> 
<script src="js/vendor/reflect-metadata/Reflect.js"></script> 
<script src="js/vendor/systemjs/dist/system.src.js"></script> 
<script src="https://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.8/hammer.js"></script> 

<script src="systemjs.config.js"></script> 
</head> 
<body> 

<my-app> 

</my-app> 

<script> 
    System.import('app').catch(function(err){ console.error(err); }); 
</script> 
</body> 
</html> 

的package.json

{ 
    "name": "example", 
    "version": "0.0.0", 
    "private": true, 
    "scripts": { 
    "start": "node ./bin/www", 
    "postinstall": "typings install", 
    "typings": "typings", 
    "vendor": "gulp vendor", 
    "gulp": "gulp clean && gulp", 
    "build:production": "gulp clean && gulp build && node systemjs.builder.js" 
    }, 
    "dependencies": { 
    "@angular/common": "2.0.0", 
    "@angular/compiler": "2.0.0", 
    "@angular/core": "2.0.0", 
    "@angular/forms": "2.0.0", 
    "@angular/http": "2.0.0", 
    "@angular/platform-browser": "2.0.0", 
    "@angular/platform-browser-dynamic": "2.0.0", 
    "@angular/router": "3.0.0", 
    "@angular/upgrade": "2.0.0", 
    "angular2-in-memory-web-api": "0.0.20", 
    "body-parser": "~1.13.2", 
    "bootstrap": "^3.3.6", 
    "cookie-parser": "~1.3.5", 
    "core-js": "^2.4.1", 
    "debug": "~2.2.0", 
    "es6-shim": "^0.35.0", 
    "express": "~4.13.1", 
    "hbs": "~3.1.0", 
    "jsonwebtoken": "^7.1.9", 
    "mongoose": "^4.6.1", 
    "morgan": "~1.6.1", 
    "q": "^1.4.1", 
    "reflect-metadata": "^0.1.3", 
    "request": "^2.75.0", 
    "rxjs": "5.0.0-beta.12", 
    "serve-favicon": "~2.3.0", 
    "systemjs": "0.19.27", 
    "typings": "^0.8.1", 
    "zone.js": "^0.6.23" 
    }, 
    "devDependencies": { 
    "del": "^2.2.0", 
    "gulp": "^3.9.1", 
    "gulp-sourcemaps": "^1.6.0", 
    "gulp-typescript": "^2.13.6", 
    "systemjs-builder": "^0.15.19" 
    } 
} 

systemjs.config.js

/** 
* System configuration for Angular samples 
* Adjust as necessary for your application needs. 
*/ 
(function (global) { 
    System.config({ 
     paths: { 
      // paths serve as alias 
      'npm:': 'js/vendor/' 
     }, 
     // map tells the System loader where to look for things 
     map: { 
      // our app is within the app folder 
      app: 'js/app', 
      // angular bundles 
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js', 
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js', 
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js', 
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js', 
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js', 
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js', 
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js', 
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js', 
      // other libraries 
      'rxjs':      'npm:rxjs', 
      'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api', 
     }, 
     // packages tells the System loader how to load when no filename and/or no extension 
     packages: { 
      app: { 
       main: './boot.js', 
       defaultExtension: 'js' 
      }, 
      rxjs: { 
       defaultExtension: 'js' 
      }, 
      'angular2-in-memory-web-api': { 
       main: './index.js', 
       defaultExtension: 'js' 
      } 
     } 
    }); 
})(this); 

回答

1

你有ES6在你tsconfig.json目標是什麼?如果你改變它爲es5,它應該工作。不幸的是,es6的Safari支持非常糟糕。 我嘗試過使用core-js墊片,但那也不起作用。

如果你仍然想使用迷死一樣的諾言,你要添加...

"files": [ 
    "../node_modules/typescript/lib/lib.es6.d.ts" 
], 
"include": [ 
    "./*.*.ts" // where ever your typescript files are 
] 

...您tsconfig爲好。這對我有效。