javascript - 应用上下文时出错 TypeError : Cannot read property 'getReferences' of null Error

标签 javascript java null widget mendix

应用程序抛出空错误,尝试了一些方法但没有运气,看起来很简单,但我一生都无法弄清楚,不确定我错过了什么。希望有人能看到这个问题。

** 日志 **

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

最佳答案

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

关于javascript - 应用上下文时出错 TypeError : Cannot read property 'getReferences' of null Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60210752/

相关文章:

javascript - 如何在多个操作之间共享对象的单个实例?

java - R.字符串比较

将字符串解析为 double 时出现 java.lang.NumberFormatException

javascript - 我如何制作这种悬停效果(悬停 1 按钮以更改元素的 ID,然后在悬停时它会变回其原始 ID?)[jquery,css3]

javascript - 如何检测 iframe 脚本何时执行?

java - 隐藏类库 - Android

java - 为什么 null 被禁止作为注释中的默认值?

node.js - Node /更新/API/序列化 : UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'email' of null

C#:对象变量应该赋值给 null 吗?

Javascript:Promise() .then 不起作用