代碼如下:var body = document.querySelector('body');body.style.background = '#000';console.log(body.style.background);// "rgb(0, 0, 0)"body.style.background.substr(this.length);// "gb(0, 0, 0)"這里面的this到底指向了哪個東西? 單獨log出來找不到相關length為1的對象啊?PS: 原本打算簡化相應的代碼, substr用來過濾px|vh等單位
JS關于dom結構中的this該怎么判斷?
BIG陽
2019-02-20 22:19:28