2016-09-28 66 views
0
class Videos extends React.Component{ 
    constructor(){ 
     super(); 
     videoslist:[]; 
    } 


    _getVideo(skip,limit){ 

     var self= this;  
     var sess=localStorage.getItem("sessionId"); 

     $.ajax({ 
      method:'GET', 
      url:'videos', 
      data:{'sessionId':sess, 
       'skip':skip, 
       'limit':limit}, 
      success:function(res){ 
       this.setState({videoslist:res.data}) 
      }.bind(this) 
     });  
    } 
componentWillMount(){ 
     this._getVideo(0,10); 
    } 

遗漏的类型错误:无法读取零遗漏的类型错误的特性“videoslist”:无法读取空如何得到这个反应Ajax响应,并设置状态

回答

1

的特性“_currentElement”你有错误的状态初始化

constructor(){ 
    super(); 
    this.state = { 
     videoslist: [] 
    } 
} 
+0

谢谢你的工作 –

+0

那么有什么问题使这个作为接受的答案? –

+0

maxx是正确的答案 –