推荐几款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;
                }
            }
        });


  • 2019-10-16 21:02:47

    vue中mixins的详细分析一

    混入 (mixins): 是一种分发 Vue 组件中可复用功能的非常灵活的方式。混入对象可以包含任意组件选项。当组件使用混入对象时,所有混入对象的选项将被混入该组件本身的选项。

  • 2019-10-16 21:04:47

    vue中mixins的详细分析二

    当混合里面包含异步请求函数,而我们又需要在组件中使用异步请求函数的返回值时,我们会取不到此返回值,如下: