typescript 基本路由
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了typescript 基本路由相关的知识,希望对你有一定的参考价值。
<router-outlet></router-outlet>
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import {AppRoutingModule, routingComponents} from './app-routing/app-routing.module';
@NgModule({
declarations: [
AppComponent,
routingComponents
],
imports: [
BrowserModule,
AppRoutingModule,
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {HomeComponent} from '../components/home/home.component';
import {ProfileComponent} from '../components/profile/profile.component';
const routes: Routes = [
{path: '', redirectTo: '/home', pathMatch: 'full'},
{path: 'home', component: HomeComponent},
{path: 'profile', component: ProfileComponent},
{path: '**', component: HomeComponent}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
declarations: []
})
export class AppRoutingModule {
}
export const routingComponents = [
HomeComponent,
ProfileComponent
];
以上是关于typescript 基本路由的主要内容,如果未能解决你的问题,请参考以下文章
typescript 路由配置:基本形式
typescript 基本的子路由
转换为TypeScript时,骨干路由不起作用
Vue + VueX + Typescript + Vue 路由器。组件未销毁
typescript 路由配置:多重路由
typescript 路由配置:子路由