Javascript 电子中含量的黑边
我用electron把用Phaser2制作的视频游戏转换成.exe。但在我的内容周围,我有一些边界或空白 我试着用全屏来改变这一点,我也试着用useContentSize,但问题没有解决 这是我的JS文件:Javascript 电子中含量的黑边,javascript,node.js,npm,electron,Javascript,Node.js,Npm,Electron,我用electron把用Phaser2制作的视频游戏转换成.exe。但在我的内容周围,我有一些边界或空白 我试着用全屏来改变这一点,我也试着用useContentSize,但问题没有解决 这是我的JS文件: const { app, BrowserWindow } = require('electron') let win; function createWindow () { // Cree la fenetre du navigateur. win = new BrowserWin
const { app, BrowserWindow } = require('electron')
let win;
function createWindow () {
// Cree la fenetre du navigateur.
win = new BrowserWindow({
//width: 886,
//height: 473,
useContentSize : true,
autoHideMenuBar : true,
icon: "favicon.ico",
//met la fenetre sans bordure
//frame : false,
//fullscreen : true,
})
//load the index.html.
win.loadFile('src/junkbuster.html');
win.setMenuBarVisibility(false);
win.setMenu(null);
//win.setContentSize(1700,1200);
}
app.on('ready', function(){
createWindow();
console.log(win.getContentBounds());
//800,600 => 786, 563
console.log(win.getSize()+"=>"+win.getContentSize());
});
这是我的HTML文件
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<script src="./phaser.js"></script>
<script src="./index.js"></script>
<style type="text/css">
body {
background-color: black;
width:100vw;
height:100vh;
margin:0px;
}
body * {
margin-left: auto;
margin-right: auto;
}
</style>
</head>
<body>
</body>
</html>
身体{
背景色:黑色;
宽度:100vw;
高度:100vh;
边际:0px;
}
正文*{
左边距:自动;
右边距:自动;
}
这个问题来自相位器2的定标器。因此,要解决这个问题,您需要转到bootinit文件并更改scaleMode的设置
转到以获取更多信息根据,对我有效的解决方法是避免main window.setresizeable(false)
,并改用此选项:
mainWindow.on('will-resize', (e) => {
//prevent resizing even if resizable property is true.
e.preventDefault();
});
提供HTML和CSSThanks这是完美的