>  기사  >  위챗 애플릿  >  WeChat 개발 마이크로사이트 jquery_mobile 사례 분석

WeChat 개발 마이크로사이트 jquery_mobile 사례 분석

高洛峰
高洛峰원래의
2017-03-24 14:27:531836검색

이 강의에서는 주로 jquery_mobile을 사용하여 영화를 재생하는 웹사이트를 구현합니다.

jquery_mobile(줄여서 JQM)은 실제로 모바일 클라이언트의 탐색 요구 사항에 맞게 jquery를 기반으로 개발된 모바일 프레임워크 세트입니다.

jquery_mobile 컨트롤 소개

jquery_mobile의 구문은 데이터 역할 형식으로 각 컨트롤(위젯)의 스타일을 정의합니다. 직접 인용하여 휴대폰에 적합한 페이지 표시 스타일입니다.

juqery_mobile의 일반적인 컨트롤은 다음과 같습니다:

WeChat 개발 마이크로사이트 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>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>页面脚注</h1>
            </div>
        </div>
        
        <div data-role="page" id="page2">
            <div data-role="header">
                <h1>header2</h1>
            </div>
            <div data-role="content">
                <img     style="max-width:90%" src="http://i.cnblogs.com/images/adminlogo.gif" / alt="WeChat 개발 마이크로사이트 jquery_mobile 사례 분석" >
            </div>
            <div data-role="footer">
                <h1>页面脚注</h1>
            </div>
        </div>
        
        <div data-role="page" id="page3">
            <div data-role="header">
                <h1>header3</h1>
            </div>
            <div data-role="content">
                内容3
            </div>
            <div data-role="footer">
                <h1>footer3</h1>
            </div>
        </div>
        
        <div data-role="page" id="page4">
            <div data-role="header">
                <h1>header4</h1>
            </div>
            <div data-role="content">
                <b>内容4</b>
            </div>
            <div data-role="footer">
                <h1>footer4    </h1>
            </div>
        </div>
        
        <div data-role="page" id="page5">
            <div data-role="header">
                <h1>header5</h1>
            </div>
            <div data-role="content">
                <h1>内容5</h1>
            </div>
            <div data-role="footer">
                <h1>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>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>页面脚注</h1>
            </div>
        </div>
        
        <div data-role="page" id="page2">
            <div data-role="header">
                <h1>header2</h1>
            </div>
            <div data-role="content">
                <img     style="max-width:90%" src="http://i.cnblogs.com/images/adminlogo.gif" / alt="WeChat 개발 마이크로사이트 jquery_mobile 사례 분석" >
            </div>
            <div data-role="footer">
                <h1>页面脚注</h1>
            </div>
        </div>
        
        <div data-role="page" id="page3">
            <div data-role="header">
                <h1>header3</h1>
            </div>
            <div data-role="content">
                内容3
            </div>
            <div data-role="footer">
                <h1>footer3</h1>
            </div>
        </div>
        
        <div data-role="page" id="page4">
            <div data-role="header">
                <h1>header4</h1>
            </div>
            <div data-role="content">
                <b>内容4</b>
            </div>
            <div data-role="footer">
                <h1>footer4    </h1>
            </div>
        </div>
        
        <div data-role="page" id="page5">
            <div data-role="header">
                <h1>header5</h1>
            </div>
            <div data-role="content">
                <h1>内容5</h1>
            </div>
            <div data-role="footer">
                <h1>footer5</h1>
            </div>
        </div>
    </body>
<html>

위의 코드에서 jquery_mobile이 ecshop 백엔드에 제품을 추가하는 것과 마찬가지로 ID를 통해 다음 목록을 제어할 수 있다는 것을 확실히 이해할 수 있습니다.

What you 주의해야 할 것은 아래 그림과 같이 빨간색 테두리 안의 코드입니다:

WeChat 개발 마이크로사이트 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에 액세스하면 효과는 다음과 같습니다.

WeChat 개발 마이크로사이트 jquery_mobile 사례 분석

우리 휴대폰은 모든 링크를 수신합니다. 푸시된 정보를 클릭하여 입력할 수도 있으며 아래와 같이 브라우저를 축소하여 jquery_mobile의 성공적인 크기 조정 효과를 확인할 수도 있습니다.

WeChat 개발 마이크로사이트 jquery_mobile 사례 분석

위 내용은 WeChat 개발 마이크로사이트 jquery_mobile 사례 분석의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.