const config = { attributes: true, childList: true, subtree: true };
const callback = (mutationsList, observer) => {
let getBoundingClientRect = this.getBoundingClientRect()
console.log('postion', `left: ${getBoundingClientRect.left}`, `bottom: ${getBoundingClientRect.bottom}`, mutationsList)
};
const observer = new MutationObserver(callback);
observer.observe(this, config);
JS监听DOM位置移动
最新推荐文章于 2023-06-16 11:33:18 发布