搜尋
首頁微信小程式微信開發微信開發微網站之jquery_mobile案例分析

這堂課我們主要用到jquery_mobile來實現一個點電影播放網站

jquery_mobile(簡稱JQM)其實就是基於jquery開發出來的一套行動裝置框架,適應行動用戶端市場對瀏覽與體驗從而進一步的提升

jquery_mobile控制介紹

jquery_mobile的語法將各個控制項(widget)以data-role的形式定義好樣式,使用時直接引用,則可呼叫適合手機頁面顯示的樣式。

juqery_mobile的常用控制項如下所示:

微信開發微網站之jquery_mobile案例分析

#我們廢話不多說,開始寫第一個jquery_mobile的模版程序,改名為jqm1.html ,程式碼如下所示:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <!--宽高禁缩放 -->
        <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
        <!--类webapp--> 
        <meta name="apple-mobile-web-app-capable" content="yes">
        <!--状态条 --> 
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <!--电话号码不是链接 --> 
        <meta name="format-detection" content="telephone=no">
        <title>jQuery Mobile Web 应用程序</title>
        <link href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" rel="stylesheet" type="text/css"/>
        <script src="http://code.jquery.com/jquery-1.6.4.min.js" type="text/javascript"></script>
        <script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js" type="text/javascript"></script>
    </head>
    <body>
        <div data-role="page" id="page1">
            <div data-role="header">
                <h1 id="header">header</h1>
            </div>
            <div data-role="content">
                <ul data-role="listview">
                    <li><a href="#page1">第一页</a></li>
                    <li><a href="#page2">第二页</a></li>
                    <li><a href="#page3">第三页</a></li>
                    <li><a href="#page4">第四页</a></li>
                    <li><a href="#page5">第五页</a></li>
                </ul>
            </div>
            <div data-role="footer">
                <h1 id="页面脚注">页面脚注</h1>
            </div>
        </div>
        
        <div data-role="page" id="page2">
            <div data-role="header">
                <h1 id="header">header2</h1>
            </div>
            <div data-role="content">
                <img  src="/static/imghwm/default1.png"  data-src="http://i.cnblogs.com/images/adminlogo.gif"  class="lazy"     style="max-width:90%"  / alt="微信開發微網站之jquery_mobile案例分析" >
            </div>
            <div data-role="footer">
                <h1 id="页面脚注">页面脚注</h1>
            </div>
        </div>
        
        <div data-role="page" id="page3">
            <div data-role="header">
                <h1 id="header">header3</h1>
            </div>
            <div data-role="content">
                内容3
            </div>
            <div data-role="footer">
                <h1 id="footer">footer3</h1>
            </div>
        </div>
        
        <div data-role="page" id="page4">
            <div data-role="header">
                <h1 id="header">header4</h1>
            </div>
            <div data-role="content">
                <b>内容4</b>
            </div>
            <div data-role="footer">
                <h1 id="footer-nbsp-nbsp-nbsp-nbsp">footer4    </h1>
            </div>
        </div>
        
        <div data-role="page" id="page5">
            <div data-role="header">
                <h1 id="header">header5</h1>
            </div>
            <div data-role="content">
                <h1 id="内容">内容5</h1>
            </div>
            <div data-role="footer">
                <h1 id="footer">footer5</h1>
            </div>
        </div>
    </body>
<html>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <!--宽高禁缩放 -->
        <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
        <!--类webapp--> 
        <meta name="apple-mobile-web-app-capable" content="yes">
        <!--状态条 --> 
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <!--电话号码不是链接 --> 
        <meta name="format-detection" content="telephone=no">
        <title>jQuery Mobile Web 应用程序</title>
        <link href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" rel="stylesheet" type="text/css"/>
        <script src="http://code.jquery.com/jquery-1.6.4.min.js" type="text/javascript"></script>
        <script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js" type="text/javascript"></script>
    </head>
    <body>
        <div data-role="page" id="page1">
            <div data-role="header">
                <h1 id="header">header</h1>
            </div>
            <div data-role="content">
                <ul data-role="listview">
                    <li><a href="#page1">第一页</a></li>
                    <li><a href="#page2">第二页</a></li>
                    <li><a href="#page3">第三页</a></li>
                    <li><a href="#page4">第四页</a></li>
                    <li><a href="#page5">第五页</a></li>
                </ul>
            </div>
            <div data-role="footer">
                <h1 id="页面脚注">页面脚注</h1>
            </div>
        </div>
        
        <div data-role="page" id="page2">
            <div data-role="header">
                <h1 id="header">header2</h1>
            </div>
            <div data-role="content">
                <img  src="/static/imghwm/default1.png"  data-src="http://i.cnblogs.com/images/adminlogo.gif"  class="lazy"     style="max-width:90%"  / alt="微信開發微網站之jquery_mobile案例分析" >
            </div>
            <div data-role="footer">
                <h1 id="页面脚注">页面脚注</h1>
            </div>
        </div>
        
        <div data-role="page" id="page3">
            <div data-role="header">
                <h1 id="header">header3</h1>
            </div>
            <div data-role="content">
                内容3
            </div>
            <div data-role="footer">
                <h1 id="footer">footer3</h1>
            </div>
        </div>
        
        <div data-role="page" id="page4">
            <div data-role="header">
                <h1 id="header">header4</h1>
            </div>
            <div data-role="content">
                <b>内容4</b>
            </div>
            <div data-role="footer">
                <h1 id="footer-nbsp-nbsp-nbsp-nbsp">footer4    </h1>
            </div>
        </div>
        
        <div data-role="page" id="page5">
            <div data-role="header">
                <h1 id="header">header5</h1>
            </div>
            <div data-role="content">
                <h1 id="内容">内容5</h1>
            </div>
            <div data-role="footer">
                <h1 id="footer">footer5</h1>
            </div>
        </div>
    </body>
<html>

由上面這段程式碼我們可以很清楚的了解到了我們的jquery_mobile是可以透過id來控制下面的清單的,有點像ecshop後台的添加商品那塊,

要注意的是紅色邊框裡面的程式碼,如下圖所示:

微信開發微網站之jquery_mobile案例分析

#然後再寫個fs.php的程序,主要讓他向指定使用者推送連結的,程式碼如下所示:

<?php
    header(&#39;content-type:text/html;charset=utf-8&#39;);
    require_once &#39;get_token.php&#39;;
    require_once &#39;common.php&#39;;
    //这时,也可以通过客户服务接口,把这个url地址发送给用户
    $contentStr = "体验一下jquery moible \n\n http://weixin.showtp.com/jqm1.html";
    $fromUsername = &#39;oB1_6tw1NBlGdqSsTCl5anZ7MEU4&#39;;
    //使用url编码
    $contentStr = urlencode($contentStr);
    $content_arr = array(&#39;content&#39; => "{$contentStr}");
    $reply_arr = array(&#39;touser&#39; => "{$fromUsername}", &#39;msgtype&#39; => &#39;text&#39;, &#39;text&#39; => $content_arr);
    //编码成json格式
    $post = json_encode($reply_arr);
    //url解码
    $post = urldecode($post);
    $url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={$access_token}";
    http_request($url, $post);
    echo &#39;发送成功!&#39;;

然後存取fs.php效果如下所示:

微信開發微網站之jquery_mobile案例分析

我們手機端將會接收到所推送的訊息了,我們點擊進去即可,我們也可以透過用瀏覽器縮小的形式就可以看到jquery_mobile成功縮放的效果,如下圖:

微信開發微網站之jquery_mobile案例分析

以上是微信開發微網站之jquery_mobile案例分析的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

MantisBT

MantisBT

Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

將Eclipse與SAP NetWeaver應用伺服器整合。

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。