Hbuilder Development App Tutorial 07-list page

Source: Internet
Author: User
<span id="Label3"></p><p><p></p></p>Description<p><p>Next to the previous section, This section tells the list page of the homepage,</p></p><p><p>If you look at the last section, you will understand that the "home" is made up of only the Head index page and list page,</p></p><p><p>This section deals With:</p></p><p><p>1. How to open several pages</p></p><p><p>Application of 2.websql</p></p><p><p>3. Loading of page content</p></p><p><p>4. Page Implementation</p></p><p><p><br></p></p>Several ways to open a page<p><p>If you read the previous chapters you will understand that you need to give up the href jump in hbuilder,mui,</p></p><p><p>And the dedicated MUI comes with a page open way, why? List of Reports: http://ask.dcloud.net.cn/article/122<br></p></p><p><p>Here is about to explain, please follow the next section,</p></p>1.open mode<p><p>This way is simple and rough, directly open a page</p></p>2.preload mode<p><p>This way the page will be loaded ahead of time, and you need to show it when you need it, to avoid waiting and stalling.</p></p>3.subpages mode<p><p>This is a sub-page way, the first page of the index.html+list.html is this way, the sub-page is also used to implement Pull-down refresh and pull-up loading</p></p><p><p><br></p></p>Index.html<p><p>The previous section only implemented the index.html part of the page, that is, the HTML section, where the JS section, only the JS loading list page part,</p></p><p><p></p></p><p><p>Forgive me for changing the structure of the file, do not worry, eventually open source, may later change,</p></p><p><p>This is the page structure mentioned in the last section, starting with Index.js.</p></p><pre class="brush:js;toolbar:false"><pre class="brush:js;toolbar:false">Initialize Mui.init ({ subpages: [qiao.h.normalpage (' list ')]}), var main = Null;var ShowMenu = False;var Menu = Null;var add = Null;var Detail = Null;//all methods are put here Mui.plusready (function () { //initialize database initdb ();}); /initialize database function Initdb () { var db = qiao.h.db (); Qiao.h.update (db, ' CREATE table if not ' exists T_plan_day_todo (id unique, plan_title, plan_content) '); Qiao.h.update (db, ' CREATE table if not ' exists t_plan_day_done (id unique, plan_title, plan_content) '); var = qiao.h.getitem (' Help '); If (!help) { qiao.h.insertitem (' help ', ' first ');} }</pre></pre>1.mui.init<p><p>YOU'LL see at the beginning of all the pages of this thing, this thing is essential, the page is initialized,</p></p><p><p>There are many uses, sub-pages, pre-loading, various settings, and so on, this is only used in the sub-page, that is, the list.html page</p></p>2.subpages<br><p><p>Subpages is an array of JS objects, each of which is a sub-page, in the form of objects:</p></p><pre class="brush:js;toolbar:false"><pre class="brush:js;toolbar:false">{ url:your-subpage-url,//child page HTML address, support local address and network address id:your-subpage-id,//child page flag styles:{ top: Subpage-top-position,//sub-page top position bottom:subpage-bottom-position,//sub-page bottom position , width:subpage-width,// Child page width, default is 100% height:subpage-height,//child page height, default is 100% ... }, extras:{}//extra extension parameter }</pre></pre><p><p>Where the URL is the address of the page, you can write local, can also write on the line, in this case is list.html</p></p><p><p>ID is the flag, and later you want to get the list page on the other page by this id,</p></p><p><p>styles, is the overall style of the page, such as aspect, such as the distance from the top, the bottom of the distance, in this case, because index.html already occupied the head, so top will Open.</p></p>3. Object Documentation<p><p>See here is not wondering, these page objects, page style objects, exactly what properties, which methods,</p></p><p><p>Must be in the official website example to find, too laborious,</p></p><p><p>In fact, all the objects in the MUI are objects in the nativejs, and here are two:</p></p><p><p>Webview:http://www.dcloud.io/docs/api/zh_cn/webview.html<br></p></p><p><p>Webviewstyle:http://www.dcloud.io/docs/api/zh_cn/webview.html#plus.webview.webviewstyle<br></p></p>4.plusready<p><p>It says that MUI is a ui+ part of the Nativejs package,</p></p><p><p>and Nativejs want to call all need to wait Nativejs complete, in MUI is mui.plusready,</p></p><p><p>Basically the outermost method of each page is a mui.init responsible for initializing, a mui.plusready responsible for the page method execution</p></p>5. Initializing the database<p><p>The above describes so much, in fact index.js here only to do two things,</p></p><p><p>One is the mui.init in the initialization of the sub-page list.html,</p></p><p><p>One is to initialize the database in Mui.plusready</p></p>6. Data Storage<p><p>To make an app, since data storage is not needed,</p></p><p><p>If it is only local app that uses local storage, websql enough;</p></p><p><p>If it's a connected app, you can mui.ajax to request it.</p></p><p><p>This tutorial is for local apps, using local storage and websql,</p></p><p><p>At the end of the index.js you can see help-related content,</p></p><p><p>probably, If there is no help on the local new help, if there is no Action.</p></p><p><p>Websql can be described here: HTTP://UIKOO9.COM/BOOK/CHAPTERDETAIL/5</p></p>7. Source Code<p><p>See here is not being index.js in some of the package scare, in fact very simple, here is the source Code.</p></p><p><p><br></p></p>Think about<p><p>Now stop and think about the process,</p></p><p><p>App Open--load Index.html--load index.js</p></p><p><p>Loading list.html sub-pages via Mui.init</p></p><p><p>Initializing the database via Mui.plusready (with websql)</p></p><p><p>Writes the local Help=first key value (used to local Storage) when the app first launches</p></p><p><p><br></p></p>List.html Page Source code<pre class="brush:html;toolbar:false"><! DOCTYPE html>

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.