简体   繁体   English

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

[英]How do I re-center an electron window after dynamically resizing?

After calling 打电话后

remote.getCurrentWindow().setSize(width, height);

the window resizes, but is not positioned in the center of the screen. 窗口会调整大小,但不会位于屏幕中央。 Is there a way to adjust the offset of the window relative to the screen? 有没有一种方法可以调整窗口相对于屏幕的偏移量?

There is a .center() method on BrowserWindow , so 有一个.center()上方法BrowserWindow ,所以

const win = remote.getCurrentWindow();
win.setSize(width, height);
win.center();

centers the window after resizing. 调整大小后将窗口居中。

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

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