移動端web app開發備忘

來源:互聯網
上載者:User

標籤:移動   web app   web開發   html5   手機   

最近要做個手機html5的頁面,做些知識儲備,重要的點記錄下來以備後續。

1.devicePixelRatio:定義裝置物理象素和裝置獨立象素的比例。css中的px可以看作是裝置的獨立象素,通過devicePixelRatio,就可以知道裝置上的一個css像素代表著多少個物理像素,可以考慮devicePixelRatio+rem進行不同裝置間的適配;

2.利用Image對象實現圖片的懶載入,主要邏輯代碼如下:

var len = queue.length;var counter = 0;for(var i = 0; i < len; i++){var img = new Image();img.src = Zepto(queue[i]).data("url");img.onload = function(){counter++;if(counter >= len){Logic.onLoadComplete();}}}
通過new Image()建立Image對象,然後監聽其onload事件,當載入完成後進行載入完畢的處理。

3.Zepto.js,專為移動端web開發,更小更輕便,API和jquery類似。中文手冊地址:http://www.html-5.cn/Manual/Zepto

移動端web app開發備忘

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.