<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    limq

    rainman
    隨筆 - 19, 文章 - 2, 評論 - 115, 引用 - 1
    數(shù)據(jù)加載中……

    MUI 上拉加載 完整實(shí)例

     例子是參照網(wǎng)上的MUI豆瓣電影,但是android上有一個(gè)問題 上拉后卡主不能動(dòng),并且提示

     Ignored attempt to cancel a touchmove event with cancelable=false
    查了很多,最后解決的方案是 阻止了冒泡事件。

      1<!DOCTYPE html>
      2<html>
      3
      4    <head>
      5        <meta charset="UTF-8">
      6        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
      7        <title>首頁</title>
      8        <script src="js/mui.min.js"></script>
      9        <link href="css/mui.min.css" rel="stylesheet" />
     10        <link href="css/style.css" rel="stylesheet" />
     11        <style>
     12            html,
     13            body {
     14                background-color: white;
     15            }

     16            
     17            .wrap-search {
     18                margin: 15px;
     19                background: #E6E6E6;
     20                height: 30px;
     21                border-radius: 5px;
     22                text-align: center;
     23            }

     24            
     25            .item-img {
     26                width: 60px;
     27                height: 90px;
     28                margin-right: 10px;
     29            }

     30        
    </style>
     31    </head>
     32
     33    <body>
     34        <div class="mui-content" style="background: white;">
     35            <div class="wrap-search">
     36                <span class="mui-icon mui-icon-search" style="line-height: 30px; color: #AAAAAA; font-size: 16px;"></span>
     37                <span style="line-height: 30px; color: #AAAAAA; font-size: 14px;">電影/電視劇/影人</span>
     38            </div>
     39
     40            <div id="refreshContainer" class="mui-scroll-wrapper" >
     41                <div class="mui-scroll">
     42                    <ul class="mui-table-view" id="movies">
     43                        <li class="mui-table-view-cell" v-for="item in movies">
     44                            <img class="item-img mui-pull-left" :src="item.cover" />
     45                            <div class="mui-ellipsis dark-big">
     46                                {{item.title}}
     47                            </div>
     48                            <div class="mui-ellipsis ">
     49                                <span class="gray-small">{{ item.genres}}</span>&nbsp;
     50                                <span v-if="item.score>0" class="orange-small"> {{item.score}}分</span>
     51                                <span v-else class="orange-small">暫無評分</span>
     52                            </div>
     53
     54                            <div class="mui-ellipsis gray-small">
     55                                導(dǎo)演:{{item.directors}}
     56                            </div>
     57                            <div class="mui-ellipsis gray-small">
     58                                主演:{{item.casts}}
     59                            </div>
     60                        </li>
     61
     62                    </ul>
     63                </div>
     64
     65            </div>
     66        </div>
     67
     68        <script src="js/vue.min.js"></script>
     69        <script src="js/util.js"></script>
     70        <script type="text/javascript">
     71            var data_movies = new Vue({
     72                el: '#movies',
     73                data: {
     74                    movies: []
     75                }

     76            }
    );
     77
     78            var aniShow = {};
     79
     80            mui.init({
     81                swipeBack: true//啟用右滑關(guān)閉功能
     82                pullRefresh: {
     83                    container: "#refreshContainer"//下拉刷新容器標(biāo)識(shí),querySelector能定位的css選擇器均可,比如:id、.class等
     84                    down: {
     85                        auto: false//可選,默認(rèn)false.首次加載自動(dòng)上拉刷新一次
     86                        callback: refreshData //必選,刷新函數(shù),根據(jù)具體業(yè)務(wù)來編寫,比如通過ajax從服務(wù)器獲取新數(shù)據(jù);
     87                    }
    ,
     88                    up: {
     89                        height: 50//可選.默認(rèn)50.觸發(fā)上拉加載拖動(dòng)距離
     90                        auto: true//可選,默認(rèn)false.自動(dòng)上拉加載一次
     91                        contentrefresh: "正在加載"//可選,正在加載狀態(tài)時(shí),上拉加載控件上顯示的標(biāo)題內(nèi)容
     92                        contentnomore: '沒有更多數(shù)據(jù)了', //可選,請求完畢若沒有更多數(shù)據(jù)時(shí)顯示的提醒內(nèi)容;
     93                        callback: loadmorData //必選,刷新函數(shù),根據(jù)具體業(yè)務(wù)來編寫,比如通過ajax從服務(wù)器獲取新數(shù)據(jù);
     94                    }

     95                }

     96            }
    );
     97
     98            // 刷新數(shù)據(jù) 重新調(diào)用接口
     99            function refreshData() {
    100                // 請求熱映列表接口    
    101                mui.getJSON(baseUrl + 'movie/in_theaters', {
    102                    start: 0,
    103                    count: 10
    104                }
    function(resp) {
    105                    data_movies.movies.splice(0, data_movies.movies.length);
    106                    data_movies.movies = data_movies.movies.concat(convert(resp.subjects));
    107                    mui('#refreshContainer').pullRefresh().endPulldownToRefresh();
    108                    mui('#refreshContainer').pullRefresh().refresh(true);
    109                }
    )
    110
    111            }

    112            
    113            var tatalCount = 0;
    114            // 加載分頁
    115            function loadmorData() {
    116                if(data_movies.movies.length  > tatalCount ){
    117                    mui.toast('我是有底線的.');
    118                    return;
    119                }

    120                // 請求熱映列表接口    
    121                mui.getJSON(baseUrl + 'movie/in_theaters', {
    122                    start: data_movies.movies.length,
    123                    count: 10
    124                }
    function(resp) {
    125                    data_movies.movies = data_movies.movies.concat(convert(resp.subjects));
    126                    tatalCount = resp.total ;
    127                    mui('#refreshContainer').pullRefresh().endPullupToRefresh(data_movies.movies.length > resp.total);
    128                }
    )
    129
    130            }

    131            
    132            mui.plusReady(function() {
    133                var self = plus.webview.currentWebview(),
    134                    nviews = self.getSubNViews(),
    135                    subpages = util.options.subpages;
    136                // 創(chuàng)建子webview窗口 并初始化
    137                util.initSubpage(aniShow);
    138                activePage = plus.webview.currentWebview();
    139
    140                //給每個(gè)view 添加監(jiān)聽點(diǎn)擊切換
    141                for(var i = 0; i < 3; i++{
    142                    nviews[i].addEventListener('click', clickEvent, false);
    143                }

    144
    145                // 自定義 tab 點(diǎn)擊事件
    146                function clickEvent(e) {
    147                    var currId = e.target.id,
    148                        currIndex = parseInt(currId.substr(currId.length - 11- 1),
    149                        currView = self.getStyle().subNViews[currIndex];
    150                    // 匹配對應(yīng)tab窗口    
    151                    if(currIndex > 0{
    152                        targetPage = plus.webview.getWebviewById(subpages[currIndex - 1]);
    153
    154                    }
     else {
    155                        targetPage = plus.webview.currentWebview();
    156                    }

    157
    158                    if(targetPage == activePage) {
    159                        return;
    160                    }

    161
    162                    if(currIndex !== 3{
    163                        //底部選項(xiàng)卡切換
    164                        util.toggleNview(currView, currIndex);
    165                        // 子頁面切換
    166                        util.changeSubpage(targetPage, activePage);
    167                        //更改當(dāng)前活躍的頁面
    168                        activePage = targetPage;
    169                    }

    170                }

    171                
    172                
    173                
    174            }
    );
    175
    176            // 添加點(diǎn)擊事件
    177
    178            mui('.wrap-search')[0].addEventListener('tap', function() {
    179                console.log('click .0')
    180            }
    )
    181
    182            mui('.mui-scroll-wrapper').scroll({
    183                indicators: false
    184            }
    );
    185            
    186            mui('.mui-scroll-wrapper')[0].addEventListener('touchmove', function (e) {
    187               e.stopPropagation();
    188            }
    );
    189//
    190//            function buffer(fn, ms) {
    191//              var timeout;
    192//              return function() {
    193//                if (timeout) return;
    194//                var args = arguments;
    195//                timeout = setTimeout(function() {
    196//                  timeout = null;
    197//                  fn.apply(null, args);
    198//                }, ms);
    199//              }
    200//            }
    201//            
    202//            document.querySelector('.mui-scroll-wrapper').onScroll = buffer(onScroll, 100);
    203            
    204            
    205            
    206            // 數(shù)據(jù)轉(zhuǎn)換
    207            function convert(items) {
    208                var newItems = [];
    209
    210                items.forEach(function(item) {
    211                    var genres = item.genres.toString().replace(/,/g, '/');
    212                    // 導(dǎo)演
    213                    var directors = '';
    214                    for(var i = 0; i < item.directors.length; i++{
    215                        directors += item.directors[i].name;
    216                        if(i != item.directors.length - 1{
    217                            directors += ' / ';
    218                        }

    219
    220                    }

    221
    222                    // 演員
    223                    var casts = '';
    224                    for(var i = 0; i < item.casts.length; i++{
    225                        casts += item.casts[i].name;
    226                        if(i != item.casts.length - 1{
    227                            casts += ' / ';
    228                        }

    229
    230                    }

    231
    232                    newItems.push({
    233                        id: item.id,
    234                        title: item.title,
    235                        genres: genres,
    236                        cover: item.images.large,
    237                        score: item.rating.average,
    238                        directors: directors,
    239                        casts: casts
    240                    }
    )
    241
    242                }
    )
    243
    244                return newItems;
    245            }

    246        
    </script>
    247    </body>
    248
    249</html>

     

    posted on 2018-04-24 15:29 limq 閱讀(2751) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 特级av毛片免费观看| www视频在线观看免费| 免费无码黄十八禁网站在线观看| 中国亚洲女人69内射少妇| 亚洲中文字幕乱码一区| 一级毛片免费不卡在线| 亚洲视频一区二区| 亚洲私人无码综合久久网| 精品无码AV无码免费专区| 亚洲中文字幕无码专区| 亚洲AV无码专区亚洲AV桃| 色播精品免费小视频| 亚洲AV综合色区无码另类小说| 老牛精品亚洲成av人片| 美女被免费喷白浆视频| 亚洲国产综合专区电影在线 | 特级毛片全部免费播放a一级| 国产免费的野战视频| 久久噜噜噜久久亚洲va久| 九一在线完整视频免费观看| 永久黄网站色视频免费直播| 亚洲午夜久久久精品电影院| 99热这里有免费国产精品| 亚洲精品国产品国语在线| 少妇亚洲免费精品| 国产免费牲交视频| 亚洲国产精品美女久久久久| 97在线观免费视频观看| 亚洲第一精品电影网| 亚洲免费视频网站| 亚洲AV无码久久精品蜜桃| 三级网站在线免费观看| 日韩一卡2卡3卡4卡新区亚洲| 日韩毛片一区视频免费| 免费又黄又爽的视频| 国产亚洲漂亮白嫩美女在线| 国产精品国产午夜免费福利看| 亚洲最大天堂无码精品区| 成人奭片免费观看| 亚洲色欲色欱wwW在线| 好大好硬好爽免费视频|