zoukankan      html  css  js  c++  java
  • 小强的HTML5移动开发之路(47)——jquery mobile基本的页面框架

    一、单容器页面结构

    <!DOCTYPE html> 
    <html>
    <head>
    <title>Jquery mobile 基本页面框架</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link href="css/jquery.mobile-1.3.2.min.css" rel="stylesheet" type="text/css"/>
    <script src="js/jquery.js" type="text/javascript"></script>
    <script src="js/jquery.mobile-1.3.2.min.js" type="text/javascript"></script>
    </head>
    <body>
    	<div data-role="page">
        	<div data-role="header">
            	<h1>标题</h1>
            </div>
            <div data-role="content">
            	<p>内容部分</p>
            </div>
            <div data-role="footer">
            	<h4>页脚</h4>
            </div>
        </div>
    </body>
    </html>
    
    说明:<meta name="viewport" content="width=device-width,initial-scale=1">设置浏览器的缩放宽度与等级,可以使页面的宽度与移动设备的屏幕宽度相同。

    二、多容器页面结构

    <!DOCTYPE html> 
    <html>
    <head>
    <title>Jquery mobile 基本页面框架</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link href="css/jquery.mobile-1.3.2.min.css" rel="stylesheet" type="text/css"/>
    <script src="js/jquery.js" type="text/javascript"></script>
    <script src="js/jquery.mobile-1.3.2.min.js" type="text/javascript"></script>
    </head>
    <body>
    	<div data-role="page" id="p1">
        	<div data-role="header">
            	<h1>标题</h1>
            </div>
            <div data-role="content">
            	<p>内容部分</p>
                <a href="#p2">下一页</a>
            </div>
            <div data-role="footer">
            	<h4>页脚</h4>
            </div>
        </div>
       	<div data-role="page" id="p2" data-add-back-btn="true">
        	<div data-role="header">
            	<h1>标题</h1>
            </div>
            <div data-role="content">
            	<p>内容部分</p>
            </div>
            <div data-role="footer">
            	<h4>页脚</h4>
            </div>
        </div>
    </body>
    </html>
    
    说明:data-add-back-btn属性表示是否在容器的左上角添加一个“回退”按钮,默认值为false.

    另外给<a>元素添加data-rel属性也可以实现回退。

    三、外部页面链接切换

    <!DOCTYPE html> 
    <html>
    <head>
    <title>Jquery mobile 基本页面框架</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link href="css/jquery.mobile-1.3.2.min.css" rel="stylesheet" type="text/css"/>
    <script src="js/jquery.js" type="text/javascript"></script>
    <script src="js/jquery.mobile-1.3.2.min.js" type="text/javascript"></script>
    </head>
    <body>
    	<div data-role="page" id="p1">
        	<div data-role="header">
            	<h1>标题</h1>
            </div>
            <div data-role="content">
            	<p>内容部分</p>
                <a href="#p2">下一页</a>
            </div>
            <div data-role="footer">
            	<h4>页脚</h4>
            </div>
        </div>
       	<div data-role="page" id="p2" data-add-back-btn="true">
        	<div data-role="header">
            	<h1>标题</h1>
            </div>
            <div data-role="content">
            	<em style="float:right;padding-right:5px">
                	<a href="about.htm">访问外部页面</a>
                </em>
            </div>
            <div data-role="footer">
            	<h4>页脚</h4>
            </div>
        </div>
    </body>
    </html>
    <!DOCTYPE html> 
    <html>
    <head>
    <title>Jquery mobile 基本页面框架</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link href="css/jquery.mobile-1.3.2.min.css" rel="stylesheet" type="text/css"/>
    <script src="js/jquery.js" type="text/javascript"></script>
    <script src="js/jquery.mobile-1.3.2.min.js" type="text/javascript"></script>
    </head>
    <body>
    	<div data-role="page" data-add-back-btn="true">
        	<div data-role="header">
            	<h1>外部页面</h1>
            </div>
            <div data-role="content">
            	你好,感谢你的关注
            </div>
            <div data-role="footer">
            	<h1></h1>
            </div>
        </div>
    </body>
    </html>
    
    如果不想以ajax方式打开页面,在链接元素中添加rel="external"

    四、预加载与页面缓存

            <div data-role="content">
            	<em style="float:right;padding-right:5px">
                	<a href="about.htm" data-prefetch="true">访问外部页面</a>
                </em>
            </div>
    使用页面缓存功能将会使DOM内容变大,一旦选择了缓存功能,要及时清理。

    将page容器的data-dom-cache设置为true,可以将该页面的内容注入文档的缓存中,或者通过js代码设置一个全局的属性,代码如下:

    $(function(){
        $.mobile.page.prototype.options.domCache = true;
    })


  • 相关阅读:
    类加载
    LinkedList插入排序实现
    99乘法表
    关于IO流的抽象类
    分解质因数
    Struts2小demo遇到的几个问题
    Tomcat设置欢迎页问题
    数据库迁移
    EF – 1.模式
    正则表达式
  • 原文地址:https://www.cnblogs.com/lanzhi/p/6469071.html
Copyright © 2011-2022 走看看