我有一个用户悬停窗口时调用的函数.是否可以改变窗户的宽度?这是我的功能:
function resize() {
console.log('resize');
}
Run Code Online (Sandbox Code Playgroud)
是的,可以访问渲染器BrowserWindowAPI.只需包含远程模块并获取当前窗口,这将允许您从主进程中执行所有操作.
例:
let { remote } = require('electron')
let win = remote.getCurrentWindow()
// Access to the renderers BrowserWindow API
win.setBounds({
width: 1000
})
win.getBounds()
// Object {x: 240, y: 192, width: 800, height: 600}
Run Code Online (Sandbox Code Playgroud)