如何从webview本身更改屏幕大小?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何从webview本身更改屏幕大小?相关的知识,希望对你有一定的参考价值。

我有一个用户悬停窗口时调用的函数。是否可以改变窗户的宽度?这是我的功能:

function resize() {
    console.log('resize');
}
答案

是的,可以访问渲染器BrowserWindow API。只需包含远程模块并获取当前窗口,这将允许您从主进程中执行所有操作。

例:

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}

参考:BrowserWindow API documentation

以上是关于如何从webview本身更改屏幕大小?的主要内容,如果未能解决你的问题,请参考以下文章