我用 Electron 开发工具。该应用程序中有两个Webview组件。一个显示html页面,另一个显示用于调试页面的chrome devtools。当前的解决方案是:
const browserContents = browserView.getWebContents()
const devtoolsContents = devtoolsView.getWebContents()
browserContents.setDevToolsWebContents(devtoolsContents)
browserContents.debugger.attach();
browserContents.openDevTools({
detach: true
})
browserContents.debugger.sendCommand( // not work
'Emulation.setTouchEmulationEnabled',
{
enabled: true,
configuration: 'mobile',
}, function(err){
if(err){console.log("Emulation err:", err);}
}
);
上面的代码可以解决问题,但是
setTouchEmulationEnabled
不起作用。所以,我想问一下关于如何解决这个问题是否有好的想法?
最佳答案
<webview-1>.addEventListener('dom-ready', () => {
require("electron").remote.webContents.fromId(<webview-1>.getWebContentsId()).setDevToolsWebContents(remote.webContents.fromId(<webview-2>.getWebContentsId()));
});
关于webview - 在 Electron 中的另一个Web View 中打开Web View 的devtools?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50759817/