我一直在摆弄电子的遥控模块.在我的主进程中,我创建了这个变量:
global.storage = {};
Run Code Online (Sandbox Code Playgroud)
我的渲染器进程初始化了一个名为startup.html的文件.
win.loadURL('file://' + __dirname + '/startup.html')
Run Code Online (Sandbox Code Playgroud)
在那里,我包含一个包含以下功能的javascript文件:
function enterMain(value){
remote.getGlobal('storage').exmpl = value;
window.location.replace('./general.html');
}
Run Code Online (Sandbox Code Playgroud)
我传递的价值是"你好",并在呼吁时......
console.log(remote.getGlobal('storage').exmpl);
Run Code Online (Sandbox Code Playgroud)
...在赋值后,它返回"hello",就像它应该的那样.但是,一旦窗口位置被替换为general.html,我在其中包含一个包含此函数的javascript文件:
$(document).ready(function(){
console.log(remote.getGlobal('storage').exmpl);
});
Run Code Online (Sandbox Code Playgroud)
...它返回undefined.为什么?任何人都可以帮我理解这个吗?