HTML5 Development App (header and Bottom tab)

Source: Internet
Author: User

Tag: Dex Bar implements a different self cloud read Note parent page

We develop apps with a certain set of styles, such as the head and bottom tabs that are part of the public sector, like the one I'm working on. The main page of the app comes in as the picture shows.

How do we do that? We should build a main page index.html, and then build five sub-pages, through the MUI to achieve the switch function.

Write down this code in the HTML section of index

<body>

&LT;H1 class= "mui-title" style= "color: #FFFFFF;" > My Cai Yuan zi


<nav class= "Mui-bar mui-bar-tab" href= "houye.html" >

<a id= "DefaultTab" class= "Mui-tab-item" href= "game.html" >
<span class= "Mui-icon iconfont icon-gamebar" ></span>
<span class= "Mui-tab-label" > My garden </span>
</a>
<a class= "Mui-tab-item" href= "nongfuzhuanqu.html" >
<span class= "Mui-icon iconfont icon-special1" ></span>
<span class= "Mui-tab-label" > Farmer zone </span>
</a>
<a class= "Mui-tab-item" href= "caiyuanshangcheng.html" >
<span class= "Mui-icon iconfont icon-iconfonticonfonticonfont20" ></span>
<span class= "Mui-tab-label" > Vegetable Market </span>
</a>
<a class= "Mui-tab-item" href= "shoplist.html" >
<span class= "Mui-icon iconfont Icon-shangcheng" ></span>
<span class= "Mui-tab-label" > Shopping list </span>
</a>
<a class= "Mui-tab-item" href= "gerenzhongxin.html" >
<span class= "Mui-icon iconfont icon-geren" ></span>
<span class= "Mui-tab-label" > Personal Center </span>
</a>
</nav>

</body>

Heard is the head style, NAV is the bottom style is obvious, attention is about the icon problem, through <span class= "Mui-icon iconfont Icon-shangcheng" ></span> Add icon But the MUI comes with the icon rarely can not meet our needs, we go to the official website http://dev.dcloud.net.cn/mui/ui/#icon可以看到

Open the tutorial according to the tutorial can be easily implemented to expand the function of the icon, simply say the tutorial, is to choose the icon you want to use, download to the local and then the corresponding CSS and font files imported into the CSS and font, you can use it generated icons. JS section to write the following code

var index=0;
The path to the page is written in the array
var subpages = [' game.html ', ' nongfuzhuanqu.html ', ' caiyuanshangcheng.html ', ' shoplist.html ', ' gerenzhongxin.html '];
All plus-* methods are written in Mui.plusready or later.
Mui.plusready (function () {
Gets the WebView window object to which the current page belongs
var self = plus.webview.currentWebview ();
for (var i = 0; i < 5; i++) {
Create a WebView child page
var sub = plus.webview.create (
Subpages[i],//Sub-page URL
Subpages[i],//sub-page ID
{
Top: ' 44px ',//set distance from top
Bottom: ' 50px '//set distance from the bottom
}
);
Hidden if not the default child page we set, otherwise added to the window
if (i! = Index) {
Sub.hide ();
}
Populating a WebView object into a window
Self.append (sub);
}
});
Current activation options
var activetab = Subpages[index],title=document.queryselector (". Mui-title");
TAB Click events
MUI ('. Mui-bar-tab '). On (' Tap ', ' a ', function (e) {

Gets the ID of the target child page
var targettab = this.getattribute (' href ');
if (Targettab = = Activetab) {
Return
}
Change title
title.innerhtml = This.queryselector ('. Mui-tab-label '). InnerHTML;
Display Destination tab
Plus.webview.getWebviewById (Targettab). reload ();
Plus.webview.show (Targettab);

Hide Current tab
Plus.webview.hide (Activetab);
Change the currently active tab
Activetab = Targettab;

});
Window.addeventlistener (' Refresh ', function (e) {//Perform refresh
Location.reload ();
});

The corresponding Word page, respectively,

The subpages array writes the path to the five child pages. All others have comments. We want to note the location of the open page, and the Click event is tap instead of our usual click. In addition, the parent and child pages are created as HTML pages that contain MUI. This will write a header and the bottom tab, the content of the sub-page is written in 5 word pages, by clicking on the Bottom tab to switch.

In the next chapter I'll talk about MUI and the different places we usually write front-end pages

HTML5 Development App (header and Bottom tab)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.