在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ angular4.x ng serve運(yùn)行沒有問題但是打包后運(yùn)行說沒有匹配的路由

angular4.x ng serve運(yùn)行沒有問題但是打包后運(yùn)行說沒有匹配的路由?

我是以這個(gè)命令“ng build --prod --aot --base-href ./”打的包!

app-routing.module.ts文件

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

const routes: Routes = [
    { path: '', loadChildren: 'app/home/home.module#HomeModule', pathMatch: 'full'}
];

const config: ExtraOptions = {
    useHash: false,
};

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

home-routing.module.ts文件

import {Routes, RouterModule} from '@angular/router';
import {HomeComponent} from './home.component';
import {NgModule} from '@angular/core';
import {HomeIndexComponent} from './home-index/home-index.component';

const routes: Routes = [
    {
        path: '',
        component: HomeComponent,
        pathMatch: 'full',
        children: [{
            path: '',
            component: HomeIndexComponent,
            pathMatch: 'full'
        }]
    }
];

@NgModule({
    imports: [RouterModule.forChild(routes)],
    exports: [RouterModule],
    providers: []

})
export class HomeRoutingModule { }

app.module.ts文件

import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { HttpModule } from '@angular/http';
import { APP_BASE_HREF } from '@angular/common';

@NgModule({
  declarations: [
      AppComponent,
  ],
  imports: [
      BrowserModule,
      BrowserAnimationsModule,
      HttpModule,
      AppRoutingModule,
  ],
  providers: [
      { provide: APP_BASE_HREF, useValue: '/' }
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

home.module.ts文件

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import {HomeRoutingModule} from './home-routing.module';
import {HomeComponent} from './home.component';
import {HomeIndexComponent} from './home-index/home-index.component';
import {HomeHeaderComponent} from './home-header/home-header.component';
import { ElModule } from 'element-angular';
import {HomeFooterComponent} from './home-footer/home-footer.component';

const HOME_COMPONENTS = [
    HomeComponent,
    HomeHeaderComponent,
    HomeIndexComponent,
    HomeFooterComponent
];

@NgModule({
  imports: [
    CommonModule,
    HomeRoutingModule,
    ElModule.forRoot()
  ],
  declarations: [
      ...HOME_COMPONENTS
  ]
})
export class HomeModule { }

請(qǐng)求各位大佬幫忙!網(wǎng)上查了重定向的方法并不好使,難道每一個(gè)path: ''都要重定向么?

回答
編輯回答
魚梓

我已解決,但是要用redirect和hash,不然找不到頁面刷新丟失頁面!

2017年6月27日 05:03
編輯回答
拼未來

解決沒,我也遇到這個(gè)問題了

2018年4月11日 18:08