Angular 2,iOS safari错误:eval @ [native code]

时间:2016-09-23 16:47:45

标签: ios angular safari

我有一个节点/ express / angular 2 app。在桌面safari / chrome中加载应用程序就可以了。没有错误。但是,如果我然后尝试将其启动到iOS Safari移动浏览器中,我会收到:

Error: eval@[native code]
invoke@http://localhost:3001/js/vendor/zone.js/dist/zone.js:203:33
run@http://localhost:3001/js/vendor/zone.js/dist/zone.js:96:49
http://localhost:3001/js/vendor/zone.js/dist/zone.js:462:60
invokeTask@http://localhost:3001/js/vendor/zone.js/dist/zone.js:236:42
runTask@http://localhost:3001/js/vendor/zone.js/dist/zone.js:136:57
drainMicroTaskQueue@http://localhost:3001/js/vendor/zone.js/dist/zone.js:368:42
g@http://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
promiseReactionJob@[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 个答案:

答案 0 :(得分:1)

你的tsconfig.json中有es6作为目标吗?如果将其更改为es5,它应该可以工作。不幸的是,es6的Safari支持非常糟糕。 我尝试使用core-js垫片,但这也没有用。

如果你仍想使用像Promise这样的超棒,你必须添加......

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

...也是你的tsconfig。这对我有用。