推荐几款vue滚动scroll插件

2020-12-01 16:49:13

浏览器滚动效果,重写滚动条,我们可以选择第三方插件。iScroll 或者 better-scroll

iScroll better-scroll 他们各有千秋,大家看着办吧。



监听滚动,做效果,我推荐  vue-scroll  ,使用这个插件,我们可以轻松的解决 

throttle

debounce

问题


throttle和debounce的区别 参考连接 throttle 和 debounce区别和用法


无论怎么找vue插件,实现div内的平滑滚动效果,还是我大 jquery,最后还是加载了jquery插件


参看地址 nuxtjs引入jquery



通过几句jquery代码实现页面平滑滚动到某一锚点的效果。实现代码来源于https://css-tricks.com/snippets/jquery/smooth-scrolling

实现的jquery代码如下:

$('a[href*="#"]:not([href="#"])').click(function() {
            if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
                var target = $(this.hash);
                target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
                if (target.length) {
                    $('html, body').animate({
                        scrollTop: target.offset().top
                    }, 1000);
                    return false;
                }
            }
        });


  • 2017-02-09 09:02:26

    两列布局——左侧宽度固定,右侧宽度自适应的两种方法

     关于左侧宽度固定,右侧宽度自适应两列布局的一种很常用的方法我相信大家都知道。就是利用左侧元素浮动,或者绝对定位的方式使其脱离常规文档流,让两个块级元素能够在同一行显示。然后右侧元素 margin-left 的值等于左侧元素宽度,这时右侧元素将紧挨着左侧元素