boylegu / SpringBoot-vue

A example demo base SpringBooot with vueJS2.x + webpack2.x as Java full stack web practice
1.96k stars 865 forks source link

Bus.$emit('filterResultData', response.data); #60

Open maxwellhertz opened 6 years ago

maxwellhertz commented 6 years ago

菜鸟想问一下 DbFilterinput.vue 里面的一行代码的作用:

            filterResultData: _.debounce(
                function () {
                    this.$axios.get("http://127.0.0.1:8000/api/persons", {
                        params: {
                            sex: this.formInline.sex,
                            email: this.formInline.email,
                        }
                    }).then((response) => {
                        response.data['sex'] = this.formInline.sex;
                        response.data['email'] = this.formInline.email;
                        Bus.$emit('filterResultData', response.data); // ?
                        console.log(response.data);
                    }).catch(function (response) {
                        console.log(response)
                    });

                },
                500
            ),

我知道_.debounce是为了限制发送 AJAX 请求的频率,但是为什么在收到后端的响应之后还要在调用一次filterResultData方法呢?