Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/416.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 动态调整大小后如何重新调整电子窗口的中心?_Javascript_Electron - Fatal编程技术网

Javascript 动态调整大小后如何重新调整电子窗口的中心?

Javascript 动态调整大小后如何重新调整电子窗口的中心?,javascript,electron,Javascript,Electron,打完电话 remote.getCurrentWindow().setSize(width, height); 窗口可调整大小,但不位于屏幕中央。有没有办法调整窗口相对于屏幕的偏移量?有一个.center()方法,所以 调整大小后将窗口居中。窗口会使用win.center()Maybe+100 px左右略微跳到顶部。 const win = remote.getCurrentWindow(); win.setSize(width, height); win.center();

打完电话

remote.getCurrentWindow().setSize(width, height);
窗口可调整大小,但不位于屏幕中央。有没有办法调整窗口相对于屏幕的偏移量?

有一个
.center()
方法,所以


调整大小后将窗口居中。

窗口会使用
win.center()
Maybe+100 px左右略微跳到顶部。
const win = remote.getCurrentWindow();
win.setSize(width, height);
win.center();