github页面上的Angular2应用程序中的路径问题

时间:2016-12-28 17:39:12

标签: angular github-pages

我是Angular2的新手,打算在github页面上设置一个小型的Angular2应用程序(当前是helloworld)。

我通过ng2-lite创建了angular-clisite托管了angular-cli。部署由gh-pages提供。它部署到angular-cli分支进行显示。

最近我发现了ng2-raw以外的另一种方法。我从头开始使用类似的代码创建ng2-raw但没有任何部署操作,托管在site

但是我在创建css时遇到了一些问题。调试后,它无法通过相对路径找到htmlts(与import { Component } from '@angular/core'; @Component({ selector: 'hello', templateUrl: './hello.component.html', styleUrls: ['./hello.component.css'] }) export class HelloComponent { name: string = 'World'; } 在同一路径下),因此我修改了路径以使其正常工作。

请查看我的两个回购中的不同代码:

github.com/MoYummy/ng2-lite/blob/master/src/app/hello.component.ts

import {Component} from 'angular2/core';

@Component({
    selector: 'hello',
    templateUrl: './app/hello.component.html',
    styleUrls: ['./app/hello.component.css']
})
export class HelloComponent {
    name: string = 'ng2';
}

github.com/MoYummy/ng2-raw/blob/gh-pages/helloworld/app/hello.component.ts

Redirect /signup ...

为什么我必须更新这些路径?如果代码结构将来变得复杂或者我试图将一个组件移动到子文件夹会怎么样?

部署Angular2应用程序的两种方式之间有什么区别?

1 个答案:

答案 0 :(得分:0)

在咨询了这个repo的作者后,他告诉我他的回购利用systemjs来加载js文件。

他的网站是为了简单的演示,因此不建议以这种方式部署精简版的ng2应用程序。相反,angular-cli更好。

我想在ng-raw停止进一步探索。

相关问题