2017-07-25 23 views
1

我在離子應用程序中使用了兩個菜單,即左側和右側。如何禁用離子中的拖動菜單

如何禁用僅拖動右側菜單。我嘗試使用$ionicSideMenuDelegate.canDragContent(false),但它禁用雙方拖動。

HTML的裁判

<ion-nav-bar> 

<ion-nav-buttons side="left"> 
<button menu-toggle="left"> 
</button> 
</ion-nav-buttons> 

<ion-nav-buttons side="right"> 
<button menu-toggle="right"> 
</button> 
</ion-nav-buttons> 

</ion-nav-bar> 
+0

試試'this.menuController.swipeEnable(false);' – hrdkisback

回答

2

我怎麼能只禁用拖動右側的菜單。

重要提示:下面的答案只能在Ionic2/3

您可以使用swipeEnable(shouldEnable, menuId)方法,但只能在右側菜單中使用。由於每邊只有一個菜單,而不是id,我們可以使用邊('left''right')。

import { MenuController, ... } from 'ionic-angular'; 

@Component({ 
    templateUrl: 'app.html' 
}) 
export class MyApp { 

    constructor(private menuCtrl: MenuController, ...) { 
    this.menuCtrl.swipeEnable(false, 'right'); 

    // ... 

    } 

    // ... 

} 
+1

請您提一下離子v1的解決方案嗎?我不熟悉ionic2或以上。 ionic2和ionic3的標籤被編輯..不是我 – sam

+1

對於標籤我很抱歉,這是我的錯誤。恐怕我不熟悉Ionic v1 :( – sebaferreras

相關問題