为什么新部署的Angular应用程序不加载组件?

时间:2019-02-03 04:12:39

标签: angular nginx digital-ocean

我有一个包含以下app.module.ts文件内容的Angular应用程序。我最近将其移至DigitalOcean Droplet(Ubuntu 18),并将dist文件夹组件移至/ var / www / html文件夹后,它会加载主页,但不加载任何组件。

该网站为this,顶部导航栏中的链接不起作用,它们重定向到404错误页面。

组件可以在本地服务器(Mac)上完美加载。我什至尝试将路由路径更改为“ app / ...”,但即使这样也不起作用。

文件内容在下面。

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';

import { AppComponent } from './app.component';
import { AboutmeComponent } from './aboutme/aboutme.component';
import { ProjectsComponent } from './projects/projects.component';
import { ResumeComponent } from './resume/resume.component';
import { HomeComponent } from './home/home.component';
import { ContactComponent } from './contact/contact.component';
import { AllComponent } from './projects/all/all.component';
import { ProjectholderComponent } from  './projects/projectholder/projectholder.component';
import { SkillsComponent } from './aboutme/skills/skills.component';
import { RiderappComponent } from './projects/mobileapps/riderapp/riderapp.component';
import { SpectrumComponent } from './projects/webapps/spectrum/spectrum.component';
import { NormansprinciplesComponent } from './projects/misc/normansprinciples/normansprinciples.component';
import { WebappsComponent } from './projects/webapps/webapps.component';
import { MobileappsComponent } from './projects/mobileapps/mobileapps.component';
import { IotComponent } from './projects/iot/iot.component';
import { MiscComponent } from './projects/misc/misc.component';
import { TouchstreamComponent } from './projects/webapps/touchstream/touchstream.component';
const routes: Routes = [
   {path: '', component: HomeComponent},
   { path: 'resume', component: ResumeComponent },
   { path: 'aboutme', component: AboutmeComponent },
   { path: 'projects', component: ProjectsComponent },
   { path: 'contact', component: ContactComponent },
   { path: 'projects/all', component: AllComponent },
   { path: 'projects/webapps', component: WebappsComponent },
   { path: 'projects/webapps/touchstream', component: TouchstreamComponent 
},
{ path: 'projects/iot', component: IotComponent },
{ path: 'projects/misc', component: MiscComponent },
{ path: 'projects/mobileapps', component: MobileappsComponent },
{ path: 'projects/mobileapps/riderapp', component: RiderappComponent },
{ path: 'projects/webapps/spectrum', component: SpectrumComponent },
{ path: 'projects/misc/normansdesignprinciples', component: 
NormansprinciplesComponent }
];

 @NgModule({
   exports: [ RouterModule ],
   imports: [ RouterModule.forRoot(routes) ]
 })
export class AppRoutingModule { }

0 个答案:

没有答案