【问题标题】:How to call method from another object in object?如何从对象中的另一个对象调用方法?
【发布时间】:2022-12-09 00:53:13
【问题描述】:

当我那样使用它时非常容易

const Object = {
property: propertyFromAnotherObject.method
}

但我想用我自己的方法使用这种方法

myOwnMethod: () => {
            localStorage.setItem('Storage', null);
}

我的连接尝试以失败告终。

     MyOwnProperty: () => {
            localStorage.setItem('Storage', null);
propertyFromAnotherObject.method         },

【问题讨论】:

    标签: reactjs


    【解决方案1】:

    在propertyFromAnotherObject 方法中使用括号

      MyOwnProperty: () => {
                localStorage.setItem('Storage', null);
                propertyFromAnotherObject.method()     
       },
    

    【讨论】:

      猜你喜欢
      • 2014-08-17
      • 1970-01-01
      • 1970-01-01
      • 2013-05-23
      • 2012-10-04
      • 2021-12-28
      • 1970-01-01
      • 2014-10-08
      • 1970-01-01
      相关资源
      最近更新 更多