Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

写一个小案例

父组件:

<template>
    <components1 :scrolled="scrolled"></components1>
    <components2 :scrolled="scrolled"></components2>
    <components3 :scrolled="scrolled"></components3>
</template>
<script>
    data(){
        return{
            scrolled:0,
            //对应该页面的数据json
            data:[]
        }
    },
    methods:{
        onScroll(){
            this.scrolled = document.documentElement.scrollTop || document.body.scrollTop;
        }
    },
    mounted(){
        window.addEventListener('scroll', this.onScroll);
    }
</script>

当前的鼠标滚动位置 会不停的传递给三个组件 分别使用

这种情况会影响性能吗?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.5k views
Welcome To Ask or Share your Answers For Others

1 Answer

虽然这个值在频繁变动,但是没有问题,不要太小看 Vue 了??


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...