一、配置路由
**1、创建项目时选择路由**
**2、在app-routing.module.ts文件中引入组件并配置路由**
import { NewsComponent } from './components/news/news.component';
import { HomeComponent } from './components/home/home.component';
import { ProductComponent } from './components/product/product.component';
const routes: Routes = [
{
path:'home',component:HomeComponent
},
{
path:'news',component:NewsComponent
},
{
path:'product',component:ProductComponent
}
];
**3、在根组件**
<router-outlet></router-outlet>