我正在尝试为我的电子应用程序中的网页视图创建一个放大和缩小按钮。
目前,我是这样做的,但是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);
}
发布于 2019-03-21 00:07:09
WebView的getZoomLevel接受回调,而不是返回值。
.getZoomLevel(回调)回调函数
zoomLevel Number发送获取当前缩放级别的请求,回调将通过回调(ZoomLevel)调用。
https://stackoverflow.com/questions/55264943
复制相似问题