番薯
番薯
  • 发布:2014-12-12 12:33
  • 更新:2015-07-13 11:29
  • 阅读:3754

同一个页面预加载多个页面如何写?

分类:MUI
mui.ready(function() {  
        mui.init({  
          //preloadLimit: 5,  
          preloadPages:[{  
            id:'videoshowindex.html',  
            url:'../html/video/videoshow.html'              
          },  
          {  
            id:'dailyshowindex.html',  
            url:'../html/daily/dailyshow.html'              
          }  

          ]  
        });   

        var detailvideoPage = null;  
        //添加列表项的点击事件  
        mui('#videoajax').on('tap', 'a', function(e) {  
          var id = this.getAttribute('id');   
          //alert(id);  
          //获得详情页面  
          if(!detailvideoPage){  
            detailvideoPage = plus.webview.getWebviewById('videoshowindex.html');  
          }  
          //触发详情页面的newsId事件  
          mui.fire(detailvideoPage,'videoid',{  
            id:id  
          });  
        //打开详情页面            
          mui.openWindow({  
            id:'videoshowindex.html',  
            //url:'videoshow.html'    
          });  
        });  

        var dailydailyPage = null;  
        //添加列表项的点击事件  
        mui('#dailyajax').on('tap', 'a', function(e) {  
          var id = this.getAttribute('id');   
          var oAudiostop = document.getElementById('myaudio'+id);         
          var btnstop = document.getElementById('play'+id);  
          var videolisttypeid =  document.getElementsByName("videolisttypeid");   
          //alert(videolisttypeid[0].value);  

            oAudiostop.pause();  
            oAudiostop.currentTime = 0;  
            btnstop.src="../images/video/play.png";   

             //time=oAudio.currentTime;  
          //alert(time);  
          //alert(id);  
          //获得详情页面  
          if(!dailydailyPage){  
            dailydailyPage = plus.webview.getWebviewById('dailyshowindex.html');  
          }  
          //触发详情页面的newsId事件  
          mui.fire(dailydailyPage,'dailyid',{  
            id:id,  
            typeid:videolisttypeid[0].value,  
           // time:time  
          });  
        //打开详情页面            
          mui.openWindow({  
            id:'dailyshowindex.html',  
           // url:'../html/daily/dailyshow.html'       
          });  
        });  

});

这样写只能预加载第一个,第2个如何预加载???

2014-12-12 12:33 负责人:无 分享
已邀请:
DCloud_UNI_CHB

DCloud_UNI_CHB

你是如何判断第二个未预加载成功的?

番薯

番薯 (作者)

detailvideoPage = plus.webview.getWebviewById('videoshowindex.html');  
alert(detailvideoPage);  
//第一个打印出来是一个对象  
dailydailyPage = plus.webview.getWebviewById('dailyshowindex.html');  
alert(dailydailyPage);  
//第2个打印出来是空的,说明没有加载成功
郭冠常

郭冠常

当前页面是,下面附件里的相同目录可以加载,或打开,其他不行
/App/html/user/user.html

同样移到/App/html/user/目录下可以加载

DCloud_UNI_CHB

DCloud_UNI_CHB

你的目录以/开头,是绝对路径写法吧,换成相对路径试试呢

DCloud_UNI_CHB

DCloud_UNI_CHB

我写测试代码验证了一下,是没问题的;
你验证两个方面吧:
1、文件路径及文件名是否有错误;
2、看一下是否有其它JS错误

  • 郭冠常

    你好,你可以看看是否是不能跨目录访问的问题,我移到相同目录下可以,目录不同就不行了

    2015-07-12 15:09

该问题目前已经被锁定, 无法添加新回复