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

Categories

0 votes
3.9k views
in Technique[技术] by (71.8m points)

vue 一个实时获取的参数 分别传递给多个组件 会影响性能吗

写一个小案例

父组件:

<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>

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

这种情况会影响性能吗?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...