【发布时间】:2020-08-15 22:20:41
【问题描述】:
我发现的其他 stackoverflow 问题对我没有帮助,所以我问你。如何在电子中定义 html / javascript 中的文档。出现错误:''文档未定义''。
html代码:
<div id="container">
<div id="left_panel"> left content! </div>
<div id="right_panel">
<div id="drag"></div> right content!
</div>
</div>
javascript:
const {app, BrowserWindow, Menu} = require('electron');
const url = require('url');
Menu.setApplicationMenu(false);
var isResizing = false;
var lastDownX = 0;
function boot() {
win = new BrowserWindow({
'minHeight': 300,
'minWidth': 300
})
win.loadURL(url.format({
pathname: 'index.html',
slashes: true
}))
}
app.on('ready', boot);
(function() {
var container = document.getElementById("container"),
left = document.getElementById("left_panel"),
right = document.getElementById("right_panel"),
handle = document.getElementById("drag");
handle.onmousedown = function(e) {
isResizing = true;
lastDownX = e.clientX;
};
document.onmousemove = function(e) {
// we don't want to do anything if we aren't resizing.
if (!isResizing) {
return;
}
var offsetRight = container.clientWidth - (e.clientX - container.offsetLeft);
left.style.right = offsetRight + "px";
right.style.width = offsetRight + "px";
}
document.onmouseup = function(e) {
// stop resizing
isResizing = false;
}
})();
如果我能得到帮助,那就太好了。 谢谢
【问题讨论】:
标签: javascript html dom electron