加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – Angular 2 Rc.1路由器未加载“/”组件

发布时间:2020-12-17 09:04:22 所属栏目:安全 来源:网络整理
导读:我试图使用rc.0版本中的新路由器. (实际使用rc.1)但是我无法获得加载“欢迎”组件的插座. 这是app.component.ts import { Component } from '@angular/core';import { Routes,ROUTER_DIRECTIVES} from '@angular/router';import { HeaderComponent } from '.
我试图使用rc.0版本中的新路由器. (实际使用rc.1)但是我无法获得加载“欢迎”组件的插座.

这是app.component.ts

import { Component } from '@angular/core';
import { Routes,ROUTER_DIRECTIVES} from '@angular/router';
import { HeaderComponent } from './common/header.component';
import { WelcomeComponent } from './common/welcome.component';
import { FooterComponent } from './common/footer.component';

@Component({
  selector: 'my-app',template: `
    <header-component> </header-component> 
        <router-outlet> </router-outlet> 
    <footer-component> <footer-component> 
  `,directives: [ROUTER_DIRECTIVES,HeaderComponent,WelcomeComponent,FooterComponent]
})

@Routes([
    {path: "/",component: WelcomeComponent}
]) 

export class AppComponent { 


}

这是main.ts

import { bootstrap }    from '@angular/platform-browser-dynamic';
import {ROUTER_PROVIDERS} from '@angular/router';
import { AppComponent } from './app.component';

bootstrap(AppComponent,[ROUTER_PROVIDERS]);

我不确定我失踪了什么,/应该工作的路径. index.html的基本引用也设置为“/”.我一直在挖掘源头,看看我遗失了什么,但没有找到任何东西.

这是一个已知问题 https://github.com/angular/angular/issues/8409

If you have routes setup without any router links and you don’t inject the router,initial navigation does not occur.

因此要么注入路由器,要么添加< a [routerLink] =“...”>直到此问题得到解决.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读