定时器函数的this指向

var btn = document.querySelector('button')
 btn.onclick = function () {
  定时器始 setTimeout(
  function () {
     this.disabled = false
     console.log('can click');
     console.log(this);
     // 定时器函数内的this指向window
   },
     console.log(this)
     // 定时器函数外的this指向btn
     , 3000)定时器末
 }
posted @ 2020-09-25 20:15  17135131xjt  阅读(168)  评论(0编辑  收藏  举报