把今天工做用到的能寫出來的東西給之後看

##瀏覽器窗口監聽事件
```
    window.onresize
```
##獲取窗口大小
```
    document.body.clientWidth
```
##layui
.layui是jquery的一個模塊化插件,用以前須要引入整一個layui模塊,調用其中的layui.css layui.js文件

.使用layui分頁配合接口的書寫方式
     layui.use(['laypage', 'layer'], function() {
            var laypage = layui.laypage,
                layer = layui.layer;

            //測試數據
            var data = [
                '北京',
                '上海',
                '廣州',
                '深圳',
                '贛州',
                '寧波',
                '紹興',
                '無錫',
                '蘇州',
                '徐州',

            ];

            var nums = 1; //每頁出現的數據量

            //模擬渲染
            var render = function(curr) {
                //此處只是演示,實際場景一般是返回已經當前頁已經分組好的數據
                var str = '',
                    last = curr * nums - 1;
                last = last >= data.length ? (data.length - 1) : last;
                for (var i = (curr * nums - nums); i <= last; i++) {
                    str += '<li href="$yeshu=' + i + '">' + data[i] + '</li>';
                }
                return str;
            };

            //調用分頁
            laypage({
                cont: 'demo3',
                pages: Math.ceil(data.length / nums) //獲得總頁數
                    ,
                curr: 3,
                groups: 5,
                first: 1,
                last: Math.ceil(data.length / nums),
                hash: 'yeshu',
                // first: 1,
                // last: 10,
                prev: '<em><<</em>',
                next: '<em>>></em>',
                jump: function(obj) {
                    document.getElementById('biuuu_city_list').innerHTML = render(obj.curr);
                }
            });
        });css

相關文章
相關標籤/搜索