【发布时间】:2019-07-20 11:36:34
【问题描述】:
我正在尝试将功能添加为seen here 在其他元素下方的 Web 视图中。因此,它获得的 x 和 y 值当然只是 webview 本身,但是inspectElement() 方法需要将窗口的 x 和 y 值作为一个整体来获取,而不仅仅是 webview。所以我需要能够得到整个窗口的高度,这样我就可以做一些数学运算来抵消我传递给inspectElement()的值。
This answer 当我打电话给remote.getCurrentWindow() 时出现此错误
Uncaught TypeError: Cannot read property 'getSize' of null
at click (<anonymous>:3950:147)
at CallbacksRegistry.apply (<anonymous>:1090:25)
at handleMessage (<anonymous>:898:21)
at EventEmitter.ipcRenderer.on.args (<anonymous>:888:7)
at EventEmitter.emit (<anonymous>:5163:17)
at Object.ipcNative.onInternalMessage (<anonymous>:3010:15)
所以它返回 null。因此,这个答案是不够的。我似乎在 StackOverflow 或其他网站上找不到任何关于如何从 webview 获取窗口高度,或者 webview 从窗口本身偏移多少的信息。
【问题讨论】: