问答详情
源自:2-1 HTML CSS实现瀑布流布局页面结构

浏览器说加粗的这一行有错误,哪错了?

window.onload=function(){
            waterfall('main','box');
            var dataInt={"data":[{"src":'0.jpg'},{"src":'1.jpg'},{"src":'2.jpg'},{"src":'3.jpg'}]};            
            window.onscroll=function(){             
                  if(checkScrollSlide){                       
                        var oParent=document.getElementById('main');                      
                        for(var i=0;i<dataInt.data.length;i++){                        
                              var oBox=document.createElement('div');                             
                              oBox.className='box';                                  
                              oParent.appendChild(oBox);                            
                              oPic.className='pic';                           
                              oBox.appendChild(oPic);                            
                              var oImg=document.createElement('img');
                              oImg.src="images/"+dateInt.date[i].src;                             
                              oPic.appendChild(oImg);
                        }
                        waterfall('main','box');
                  }            
            } 

}

浏览器提示

 Uncaught ReferenceError: oPic is not defined

提问者:慕课此昵称 2016-08-05 13:02

个回答

  • 慕盖茨4878874
    2016-08-05 13:35:19
    已采纳

    opic没有创建   (类似oBox,var oBox=document.createElement('div'); )要先创建