我已经在创建窗口时设置了窗口的宽度和高度,现在再次要在调用ipc主进程时更改同一窗口的宽度和高度。
这是我的代码
function createWindow() {
win = new BrowserWindow({
width: 448, // here I have set the width and height
height: 650,
frame: false,
transparent: true,
minimizable: true,
maximizable: true,
closable: true,
})
win.loadURL(url.format({
pathname: path.join(__dirname, './view/loginWindow.html'),
protocol: 'file:',
slashes: true
}))
.....
....
现在我正在调用ipc方法
ipcMain.on('userRegLinkClicked', (event, data) => {
win.setSize({
width: 448,
height: 850
})
}
但是什么都行不通,而是出现错误
TypeError: Error processing argument at index 0, conversion failure from #<Object>
最佳答案
window.setSize不接受带有width/height的options对象,而是使用width/height和其他参数作为直接参数。
改用这个:
ipcMain.on('userRegLinkClicked', (event, data) => {
win.setSize(448, 850);
}
关于electron - 如何在 Electron 中设置当前窗口的宽度和高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46755983/