this指向

1.axios。then兩種回調形式的this指向
a.箭頭函數,函數中 this 老是綁定老是指向對象自身ios

axios.ajax({  
  url:'/get/basicTable',  
 }).then(response=> {
    console.log(this) // 有值,指向當前對象
 })

b.函數中 this 指向windowajax

axios.ajax({  
  url:'/get/basicTable',  
 }).then(function(response)=> {
    console.log(this) // undefined
 })
相關文章
相關標籤/搜索