时间轴在vue js中滚动

时间:2017-03-25 08:18:30

标签: javascript vue.js laravel-5.3

<script type="text/babel">
    export default {
        data () {
            return {
                listmasters: [],
                listmastersscrolls: [],
                scrollPosition: null,
                scrollPosition1: null
            }
        },

        mounted: function () {
            this.getListMasters();
            window.addEventListener('scroll', this.updateScroll);
            window.addEventListener('scroll', this.updateScroll1);
        },

        methods: {
            getListMasters: function () {
                this.$http.get('/get-listMaster?').then((response) => {
                    this.$set(this, 'listmasters', response.data.data.data);
                });
            },

            updateScroll() {
                this.scrollPosition = window.scrollY;
                this.scrollPosition1 = 950;
            },

            updateScroll1() {
                if (window.scrollY > this.scrollPosition1) {
                    this.$http.get('/get-listMaster1?').then((response) => {
                        this.$set(this, 'listmastersscrolls', response.data.data.data);
                    });
                }
            },
        }
    }
</script>

每次我滚动大约20个请求进入后端我必须将此限制为0个请求我必须获取3个时间轴帖子3并且我已成功完成它但是对于每个滚动请求的数量去后端很高

0 个答案:

没有答案