【问题标题】:Error while applying context TypeError: Cannot read property 'getReferences' of null Error应用上下文 TypeError 时出错:无法读取 null 错误的属性“getReferences”
【发布时间】:2020-02-13 23:06:25
【问题描述】:

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

** 日志 **

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

【问题讨论】:

    标签: javascript java null widget mendix


    【解决方案1】:

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

    【讨论】:

    • 我尝试初始化它,但不起作用,我会尝试调节它的访问权限。
    • 初始化后用console.log试试看“getReferences”函数是否存在
    • 我想我可能声明变量错误,这是正确的方式 this._contextObj = ' ';?
    • if (this.rsdListContainer && this._contextObj) { 应该可以解决问题。
    • @EdLucas 你是个天才。 '完全停止'。我试图调整它的访问权限,但在错误的部分。
    猜你喜欢
    • 2021-06-07
    • 2022-06-18
    • 2017-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多