![](/img/trans.png)
[英]webview.executeJavascript function cannot find jquery- Electron
[英]Zoom Function in a Webview with Electron
我正在尝试在Electron应用程序中为Web视图创建一个放大和一个缩小按钮。
目前,我是这样做的,但是getZoomFactor
总是返回undefined
。 还有另一种创建这两个缩放按钮的方法吗?
function zoomIn() {
const webview = document.querySelector('webview');
let actualZoom = webview.getZoomFactor();
if (actualZoom == null) {
actualZoom = 1;
}
webview.setZoomFactor(actualZoom + 1);
}
function zoomOut() {
const webview = document.querySelector('webview');
let actualZoom = webview.getZoomFactor();
if (actualZoom == null) {
actualZoom = 1;
}
webview.setZoomFactor(actualZoom - 1);
}
WebView的getZoomLevel接受回调,而不返回值。
.getZoomLevel(callback)回调函数
zoomLevel Number发送请求以获取当前缩放级别,该回调将通过callback(zoomLevel)进行调用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.