检查电子窗口的大小是否改变

mes*_*ati 6 electron

我想要一个监听器(或其他东西)来检查窗口的大小是否改变,做一些事情(比如重新渲染整个视图页面)。

我该怎么做?

Mik*_*ike 13

您可以resize像这样使用该事件:

window.on('resize', function () {
    var size   = window.getSize();
    var width  = size[0];
    var height = size[1];
    console.log("width: " + width);
    console.log("height: " + height);
});
Run Code Online (Sandbox Code Playgroud)

文档在这里