有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

应用上下文TypeError时发生javascript错误:无法读取null错误的属性“getReferences”

应用程序抛出空错误,尝试了一些事情,但没有运气,似乎很简单,但无法为我的生活,不知道我错过了什么。希望有人能看到这个问题

**日志**

RouteToMarketSearch.RouteToMarketSearchSnippet.referenceSetDisplay2: Error while applying context Error: RouteToMarketSearch.RouteToMarketSearchSnippet.referenceSetDisplay2: Error while applying context TypeError: Cannot read property 'getReferences' of null Error: RouteToMarketSearch.RouteToMarketSearchSnippet.referenceSetDisplay2: Error while applying context Error: RouteToMarketSearch.RouteToMarketSearchSnippet.referenceSetDisplay2: Error while applying context TypeError: Cannot read property 'getReferences' of null

声明变量

_handles: null,
_contextObj: null,
_reference : null,
_entity : null,
_intersectReference : null,
_intersectEntity : null,

**代码**

_updateRendering: function (callback) {
    logger.debug(this.id + "._updateRendering");
    var self = this;
    if(this.rsdListContainer){
        data.get({
            guids: this._contextObj.getReferences(this._reference),
            callback: function(objs){
                if(self.rsdListContainer){
                    var intersectGuids = [];
                    if(self._intersectReference){
                        intersectGuids = self._contextObj.getReferences(self._intersectReference);
                    }

                    var dataArray = objs.map(function(o){
                        var data = {};
                        data.guid = o.getGuid();
                        data.caption = o.get(self.displayAttribute);
                        if( intersectGuids && intersectGuids.indexOf(o.getGuid()) > -1){
                            data.elementClass = self.intersetResultClass;
                        }
                        if(self.sortAttribute){
                            data.sortIndex = parseInt(o.get(self.sortAttribute));
                        }

                        return data;
                    });

                    if(self.sortAttribute){
                        dataArray.sort(function(a,b){
                                return a.sortIndex - b.sortIndex;
                        });
                    }

                    dojoConstruct.empty(self.rsdListContainer);

共 (1) 个答案

  1. # 1 楼答案

    如果您使用空值声明_contextObj,当您尝试执行this._contextObj.getReferences时,将抛出该错误。没有空值的内部实现,您需要声明它或限制其访问