箭头函数

187 阅读1分钟

//获取轮播列表

   getLunboList() {
     console.log(this)
     axios
       .post("http://192.168.1.103:82/teacher/rotation",this. lunBoInfo )
       .then(function(res) {
         console.log(res);
         const resDate = res.data.list;
         console.log(resDate)
         console.log(this)//这里 this = undefined
         this.tableList = res.data.list;
         
       })
       .catch((error)=> {
             console.log(this); //箭头函数"=>"使this指向vue
       });
        
   },
   ```