2016-11-09 34 views
0

我已經在nativescript中使用RadSideDrawer指令創建了側邊菜單,並且當我嘗試在其中加載子路由時,除了默認加載,所有後續加載都顯示爲空白屏幕。NativeScript側抽屜無法加載路由器插座

這就是我如何加載內容。

<ScrollView tkMainContent class="menu-content"> 
    <router-outlet></router-outlet> 
</ScrollView> 

導航邏輯:

<StackLayout> 

     <StackLayout orientation="horizontal" [nsRouterLink]="['./']" class="menu-item" 
       [nsRouterLinkActiveOptions]="{exact: true}" nsRouterLinkActive="active" horizontalAlignment="left"> 
      <Label text="{{inspectionsIcon}}" class="icon" ></Label> 
      <Label text="Reports"></Label> 
     </StackLayout> 

     <StackLayout orientation="horizontal" [nsRouterLink]="['properties']" class="menu-item" nsRouterLinkActive="active" horizontalAlignment="left"> 
      <Label text="{{propertiesIcon}}" class="icon" ></Label> 
      <Label text="Properties" ></Label> 
     </StackLayout> 

     <StackLayout orientation="horizontal" [nsRouterLink]="['settings']" class="menu-item" nsRouterLinkActive="active" horizontalAlignment="left"> 
      <Label text="{{settingsIcon}}" class="icon" ></Label> 
      <Label text="Settings"></Label> 
     </StackLayout> 



    </StackLayout> 

所以當父路由負載我看到默認的孩子的內容。當我切換到任何其他兒童路線時,我看到一個空白屏幕。任何幫助解決這個問題將不勝感激。

我知道,導航邏輯是好的原因它加載很好,當我剛剛註釋掉RadSideDrawer並把它作爲一個列表視圖

回答

1

我有同樣的問題,它是由於循環引用時RadSideDrawer是在同一組件模板作爲默認的家用路由器的路徑,你的情況[nsRouterLink]="['./']

在我而言,當我加入CONSOLE.LOG我HomeComponent其中載我RadSideDrawer的構造函數中,我看到的構造觸發了兩次,以及我有裏面的標籤:

<ScrollView tkMainContent class="menu-content">

解決方案(由Telerik向我推薦)是將默認路由點指向另一個「着陸頁」,如[nsRouterLink] =「['welcomPage'],從而刪除循環引用。

+0

我在加載RadSideDrawer的根組件中添加了一些斷點,並且控制器只加載一次,你能指導我參考一些代碼示例嗎? – user7138736

+0

哈哈 - 看看這個例子:https://github.com/greenstevester/nativescript-sidedrawer-example –

相關問題