如何从模块更改应用程序中 JSON 对象的值?

How to change values of a JSON object in an app from a module?

我有一个带有 JSON 对象的 JS 应用程序文件。

我想要做的是获取这个对象,将它发送到一个模块文件,更改值,然后将它发回以更改应用程序文件中 JSON 对象的值。如果说得通。

我该怎么做?

这是应用程序文件中的 JSON 对象:

NRXA.reactorOne = {
    powerOn: true,
    temperature: 10,
    pressure: 10,
    coolant: 10,
    systemFailure: false,
    performance: 10,
    powerOutput: 10
};

这是当前模块文件中我试图更改值的函数:

function setPowerOffStandardValues(reactor){
    let newReactor = reactor;

    newReactor = {
        powerOn: false,
        temperature: 0,
        pressure: 0,
        coolant: 0,
        systemFailure: false,
        performance: 0,
        powerOutput: 0
    };

    return newReactor;

}

这就是我在应用程序中调用模块函数的方式:

NRXA.reactorOne = NuclearReactorXModule.setPowerOffStandardValues(NRXA.reactorOne);

我的错误消息是 setPowerOffStandardValues 函数未定义,我不知道要更改什么,因为我完全是个菜鸟,而且我因为考试感到疲倦和压力很大,所以可能会出现明显的错误我看不到 lol

确保 export 其模块中的 setPowerOffStandardValues 函数。改成

export function setPowerOffStandardValues(reactor){

以便其他模块可以引用它。