Downloader模塊管理網絡文件下載任務,用於從服務器下載各類文件,並支持跨域訪問操做。經過plus.downloader獲取下載管理對象。Downloader下載使用HTTP的GET/POST方式請求下載文件,符合標準HTTP/HTTPS傳輸協議。javascript
步驟:css
1.建立下載對象html
2.監聽狀態java
3.開始下載
完整演示代碼跨域
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> <title></title> <script src="js/mui.min.js"></script> <link href="css/mui.min.css" rel="stylesheet"/> </head> <body> <header class="mui-bar mui-bar-nav"> <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a> <h1 class="mui-title">hello</h1> </header> <div class="mui-content"> <div style="padding:20px;"> <div style="line-height:38px;" id="dstatus">下載狀態</div> <div class="mui-progressbar" id="psb1"> <span></span> </div> </div> <div style="padding:20px;"> <button id="download" onclick="createDownload();" class="mui-btn-blue mui-pull-right">開始下載</button> <button id="download" onclick="cDownload();" class="mui-btn-red mui-pull-right" style="margin-right:10px;">取消下載</button> </div> </div> <script> mui.init(); //初始化下載對象 var dtask = null; var psb1 = mui('#psb1'); var dstatus = mui('#dstatus'); function createDownload(){ var isFile1 = false; //判斷文件是否已經下載 plus.io.resolveLocalFileSystemURL( '_downloads/Snip_V2.0_5771.dmg',