问题
I searched and didn't really find the right answer.
I have the sliding menu in the top left for the 'full menu' but I also want the tab bar at the top to highlight 3 or 4 specific links/pages. How can I have them both working? When I place the tabbar in my script, the sliding menu doesn't work right.
回答1:
There's no trouble on implementing sliding and tabbar.
<ons-sliding-menu
main-page="page1.html"
menu-page="menu.html"
side="left"
max-slide-distance="250px"
var="menu">
</ons-sliding-menu>
<ons-template id="page1.html">
<ons-page>
<ons-toolbar>
<div class="left">
<ons-toolbar-button ng-click="menu.toggleMenu()"><ons-icon icon="ion-navicon" style="font-size: 32px; width: 1em;"></ons-icon></ons-toolbar-button>
</div>
<div class="center">Page 1</div>
</ons-toolbar>
<ons-tabbar position="top">
<ons-tab page="home.html" active="true">
<ons-icon icon="ion-home"></ons-icon>
<span style="font-size: 14px">Home</span>
</ons-tab>
<ons-tab page="fav.html" active="true">
<ons-icon icon="ion-star"></ons-icon>
<span style="font-size: 14px">Favorites</span>
</ons-tab>
<ons-tab page="settings.html" active="true">
<ons-icon icon="ion-gear-a"></ons-icon>
<span style="font-size: 14px">Settings</span>
</ons-tab>
</ons-tabbar>
<ons-template id="home.html">
<ons-page>
<p style="text-align:center">Home Page</p>
</ons-page
</ons-template>
<ons-template id="fav.html">
<ons-page>
<p style="text-align:center">Favorites page</p>
</ons-page
</ons-template>
<ons-template id="settings.html">
<ons-page>
<p style="text-align:center">Settings Page</p>
</ons-page
</ons-template>
</ons-page>
</ons-template>
<ons-template id="menu.html">
<ons-list>
<ons-list-item modifier="chevron" onclick="menu.setMainPage('page1.html', {closeMenu: true})">
page1.html
</ons-list-item>
<ons-list-item modifier="chevron" onclick="menu.setMainPage('fav.html', {closeMenu: true})">
page2.html
</ons-list-item>
</ons-list>
</ons-template>
Hope this'll help. check my working codepen
回答2:
First of all, the Tabbar element is designed to be displayed, by default, on the bottom of the page:
http://onsen.io/guide/overview.html#onstabbaroverview
You can change this the position by using the attribute position="top"
For what concerns the combination sliding menu + tabbar I haven't had any problem to put the two elements together. Try to create a new Onsen UI Sliding Menu project and modify the file menu.html in this way:
<ons-navigator>
<ons-page>
<ons-tabbar position="top">
<ons-tab page="home.html" active="true">
<ons-icon icon="ion-home"></ons-icon>
<span style="font-size: 14px">Home</span>
</ons-tab>
<ons-tab page="fav.html" active="true">
<ons-icon icon="ion-star"></ons-icon>
<span style="font-size: 14px">Favorites</span>
</ons-tab>
<ons-tab page="settings.html" active="true">
<ons-icon icon="ion-gear-a"></ons-icon>
<span style="font-size: 14px">Settings</span>
</ons-tab>
</ons-tabbar>
<div style="text-align: center">
<h1>Page 1</h1>
<ons-button
ng-click="app.slidingMenu.toggleMenu()">
Toggle Menu
</ons-button>
<p> Click "Toggle Menu" to close/open menu, </p>
<p> You can also swipe the page left/right. </p>
<img src="images/ico_swipe_right_s.png" alt="">
</div>
</ons-page>
</ons-navigator>
I would like to post you a screen, but I still don't have enough reputation
来源:https://stackoverflow.com/questions/27337163/combine-onsen-ui-sliding-menu-and-tabbar