2017-10-15 99 views
0

我已经在创建窗口时设置了窗口的宽度和高度,现在我又想在我调用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>

回答

1

window.setSize没有考虑期权与宽度/高度对象,而是使用宽度/高度和附加参数作为直接参数。

使用这个代替:

ipcMain.on('userRegLinkClicked', (event, data) => { 
    win.setSize(448, 850); 
} 
相关问题