electron:BrowserWindow模块-偏移量设置

2023-05-14  本文已影响0人  大咔丶
let options = {
      width: args.width,
      height: args.height,
      resizable: false, //是否可以改变窗口size
      fullscreen: false, // 是否可以全屏幕
      frame: process.platform === 'darwin' ? true : false, // 自定义导航
      webPreferences: {
        contextIsolation: false, // 设置此项为false后,才可在渲染进程中使用electron api
        nodeIntegration: true
      },
    }
  options.maxHeight = 28
  options.x = 0 
  options.y = 0
  options.alwaysOnTop = true
  options.transparent = true
new BrowserWindow(options)

刚开始只设置了y并未生效。后来查询得知:

x Interger (可选) - (必选 如果使用了y) 窗口相对于屏幕左侧的偏移量。 默认值为将窗口居中。
y Integer (可选) - (必选 如果使用了x) 窗口相对于屏幕顶端的偏移量。 默认值为将窗口居中。

ok!

上一篇 下一篇

猜你喜欢

热点阅读