代码如下:
<html>
<head>
<style type="text/css">
* {
margin: 0;
}
</style>
</head>
<body>
<div style="position: relative; height: 100%; width: 100%;">
<div style="position: absolute; width: 100%; height: 100%; text-align: center;
position: absolute;
background-color: transparent;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 1;">
<webview style="width: 100%;
height: 100%;
" id="broswer" src="https://github.com">
</webview>
</div>
</div>
<script>
var broswer = document.getElementById('broswer');
broswer.addEventListener("dom-ready", () => {
var webContents = broswer.getWebContents();
webContents.debugger.attach('1.3');
webContents.debugger.sendCommand('Emulation.setEmitTouchEventsForMouse', { enabled: true });
webContents.debugger.sendCommand('Emulation.setTouchEmulationEnabled', {
enabled: true,
configuration: 'mobile',
});
webContents.openDevTools();
});
</script>
</body>
</html>
其中,debugger用法,请参考官网地址:https://electronjs.org/docs/api/debugger
网友评论