2

在meteor-angular2 应用程序中,当仅列出指向“前端”的路线时,一切正常。如果我添加另一条路线,如以下代码块所示,我会收到以下错误:

Uncaught (in promise) Uncaught SyntaxError: Unexpected token <
Evaluating http://localhost:3000/metis/metis
Error loading http://localhost:3000/client/app

应用程序.ts

import {Component, View, provide} from 'angular2/core';
import {ROUTER_PROVIDERS, ROUTER_DIRECTIVES, RouteConfig, APP_BASE_HREF} from 'angular2/router';
import {bootstrap} from 'angular2-meteor';
import {Frontend} from "./frontend/frontend"; 
import {Metis} from "metis/metis";

@Component({
    selector: 'app',
    template:'<router-outlet></router-outlet>',
    directives:[ROUTER_DIRECTIVES]
})
@RouteConfig([
    { path: '/', name: 'Frontend', component: Frontend },
    { path: '/metis', name: 'Metis', component: Metis  }
])
class HATViz {}

bootstrap(HATViz, [
    ROUTER_PROVIDERS,
    provide(APP_BASE_HREF, { useValue: '/' })
]);

Metis 组件如下所示:

import {Component, OnInit} from 'angular2/core';

@Component({
    templateUrl:'client/metis/metis.html',
    selector:'metis'
})
export class Metis {
}
4

1 回答 1

1

错误

Uncaught (in promise) Uncaught SyntaxError: Unexpected token <

表示 SystemJS 无法下载相应的 js 文件(服务器以索引 HTML 页面响应)。看起来您的metis组件导入不正确。应该是(注意前面的“.”):

import {Metis} from "./metis/metis";
于 2016-02-20T07:55:26.087 回答