Javascript 角度2:语法错误:意外标记<;

Javascript 角度2:语法错误:意外标记<;,javascript,typescript,angular,reactivex,Javascript,Typescript,Angular,Reactivex,我知道这类问题已经被问到了,我也提到了所有被回答的问题,但我仍然无法解决这个问题。 这个错误正好发生在我部署导入'rxjs/add/operator/fromArray'时除了此导入和可观察之外。从数组代码可以完美地工作。 我在angular 2.0.0-beta.7上 向控制台抛出错误 SyntaxError: Unexpected token <(…) Zone.run @angular2-polyfills.

我知道这类问题已经被问到了,我也提到了所有被回答的问题,但我仍然无法解决这个问题。 这个错误正好发生在我部署
导入'rxjs/add/operator/fromArray'时除了此
导入
可观察之外。从数组
代码可以完美地工作。 我在angular 2.0.0-beta.7上

向控制台抛出错误

SyntaxError: Unexpected token <(…)
Zone.run                                       @angular2-polyfills.js:1243
zoneBoundFn                                    @angular2-polyfills.js:1220
lib$es6$promise$$internal$$tryCatch            @angular2-polyfills.js:468
lib$es6$promise$$internal$$invokeCallback      @angular2-polyfills.js:480
lib$es6$promise$$internal$$publish             @angular2-polyfills.js:451
lib$es6$promise$$internal$$publishRejection    @angular2-polyfills.js:401
(anonymous function)                           @angular2-polyfills.js:123
Zone.run                                       @angular2-polyfills.js:1243
zoneBoundFn                                    @angular2-polyfills.js:1220
lib$es6$promise$asap$$flush                    @angular2-polyfills.js:262
package.json

  {
    "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
     "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
},
  "exclude": [
  "node_modules",
  "typings/main",
  "typings/main.d.ts"
   ]
 }
 {
   "name": "angular2-quickstart",
   "version": "1.0.0",
   "scripts": {
   "start": "concurrent \"npm run tsc:w\" \"npm run lite\" ",
   "tsc": "tsc",
   "tsc:w": "tsc -w",
    "lite": "lite-server",
    "typings": "typings",
    "postinstall": "typings install"
   },
    "license": "ISC",
    "dependencies": {
    "angular2": "2.0.0-beta.7",
    "bootstrap": "^3.3.6",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.33.3",
    "reflect-metadata": "0.1.2",
     "rxjs": "5.0.0-beta.2",
     "systemjs": "0.19.22",
     "zone.js": "0.5.15"
  },
     "devDependencies": {
     "concurrently": "^2.0.0",
     "lite-server": "^2.1.0",
      "typescript": "^1.7.5"
    }
   }

我认为您可以使用“from”操作符而不是“fromArray”操作符:


我认为您可以使用“from”操作符而不是“fromArray”操作符:


尝试为fromArray运算符从可观察路径导入

导入'rxjs/add/可观察的/fromArray'

下面是一个工作示例:

import {Observable} from 'rxjs/Observable'
import 'rxjs/add/operator/map'
import 'rxjs/add/observable/fromArray'

import {Component} from 'angular2/core';

@Component({
    selector: 'my-app',
    template: ``
})
export class AppComponent {
    constructor() {
        Observable.fromArray([1, 2, 3])
            .map(data => "Value = " + data)
            .subscribe(x => console.log(x));
    }
}

尝试为fromArray运算符从可观察路径导入

导入'rxjs/add/可观察的/fromArray'

下面是一个工作示例:

import {Observable} from 'rxjs/Observable'
import 'rxjs/add/operator/map'
import 'rxjs/add/observable/fromArray'

import {Component} from 'angular2/core';

@Component({
    selector: 'my-app',
    template: ``
})
export class AppComponent {
    constructor() {
        Observable.fromArray([1, 2, 3])
            .map(data => "Value = " + data)
            .subscribe(x => console.log(x));
    }
}

尝试在index.html中使用
.map
函数,即
.map:{rxjs:'node_modules/rxjs'}
对不起,我不理解你的代码:)我的意思是说尝试添加
。map:{rxjs:'node_modules/rxjs}
代码到你定义
System.config
的index.html文件中。看看这个答案还是不起作用!现在出现了什么错误?请尝试使用index.html中的
.map
函数,即
.map:{rxjs:'node_modules/rxjs'}
抱歉,我不明白您的代码:)我的意思是说尝试添加
。map:{rxjs:'node_modules/rxjs'}
代码到您定义
System.config
的index.html文件中。看看这个答案还是不起作用!现在有什么错误?
Observable.from(startDates)
    .map(date => {
      (...)
    });
import {Observable} from 'rxjs/Observable'
import 'rxjs/add/operator/map'
import 'rxjs/add/observable/fromArray'

import {Component} from 'angular2/core';

@Component({
    selector: 'my-app',
    template: ``
})
export class AppComponent {
    constructor() {
        Observable.fromArray([1, 2, 3])
            .map(data => "Value = " + data)
            .subscribe(x => console.log(x));
    }
}