this的区别

数据中心:this与_this的区别

getSelectData:function(){
                        var _this=this;
                        _this.queryAjax(URL.selectData,'','post',function(rst){
                            if(rst.ret==0){
                                _this.selectInfo = rst.results.data;
                                _this.filterArr = $.map(rst.results.data, function(obj) {
                                    return $.extend(true, {}, obj);
                                });
                                _this.filterArrSec = $.map(rst.results.data, function(obj) {
                                    return $.extend(true, {}, obj);
                                });
                                _this.ceshi= rst.message;
                                _this.tapMore();
                            }else{
                                alert('数据请求失败');
                            }
                        });
                    },

通常在一个函数中,如果包含ajax请求或者里面有重新绑定了事件,需要重新指定this;两个作用域不同

原文地址:https://www.cnblogs.com/xiaozhumaopao/p/6688705.html