简体   繁体   English

无法访问对象

[英]Not able to Access Object

this.deleteValue = {
            LanguageId : '',
            LanguageName : '',
            LongName : '',
            CreatedBy : '',
            UpdatedBy : '',
            CreatedDate : '',
            UpdateDate : '',
            IsDeleted : ''
        }

has been initialized in my component.已在我的组件中初始化。 I have assigned the value in one of my functions.我已在我的一项功能中分配了该值。

beginDel(delValue){
        this.deleteValue = new language(delValue.LanguageId, delValue.LanguageName, delValue.LongName, delValue.CreatedBy, delValue.UpdatedBy,delValue.CreatedDate,delValue.UpdateDate, delValue.IsDeleted);  
        console.log(this.deleteValue);  

    }

However, when I am try to access it in some other function, it is an empty object.但是,当我尝试在其他函数中访问它时,它是一个空对象。

 recordDel(){
        console.log(this.deleteValue);
}

I think the issue is with scoping, but I'm not able to figure out what the issue is, exactly.我认为问题在于范围界定,但我无法确切地弄清楚问题是什么。

you re-initialized it in beginDel.你在 beginDel 中重新初始化了它。 Try to call this method from inside beginDel, like this :尝试从 beginDel 内部调用此方法,如下所示:

 beginDel(delValue){
     ....
     ....    
     // add chain-call here
     recordDel();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM