js回到顶部

            scrollTop() {
                var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
                var setI = setInterval(() => {
                    scrollTop = scrollTop-scrollTop/10;
                    window.scrollTo(0, scrollTop);
                    console.log(scrollTop);
                    if (scrollTop <= 1) {
                        clearInterval(setI)
                    }
                }, 10);  
            },

你可能感兴趣的:(js,vue功能)