2016-08-16 3 views
0

jsonファイルからx、yの位置と幅、高さをロードして渡します。ここに私のコードElectron、新しいBrowserWindowのロード値

const electron = require('electron') 
const {app, BrowserWindow} = electron 
var fs = require('fs'); 
var loadsttngs = JSON.parse(fs.readFileSync('settings.json', 'utf8')); 
console.log(loadsttngs.width); 
let win 

function createWindow() { 
    win = new BrowserWindow({ 
    x: loadsttngs.x, 
    y: loadsttngs.y, 
    width: loadsttngs.width, 
    height: loadsttngs.height, 
    frame: false}) 

    win.setMenu(null) 
    win.loadURL(`file://${__dirname}/index.html`) 

    win.webContents.openDevTools() 

    // Emitted when the window is closed. 
    win.on('closed',() => { 
    //var bounds = win.getBounds(); 
    win = null 
    }) 
} 

console.log(loadsttngs.width);返り正しい値であるので、使用されていないファイルを読み込むとが、new BrowserWindowには問題は(いくつかのデフォルト値を使用してのような)はありません。 new BrowserWindowに直接値を書き込むと問題なく動作します。

settings.json { "X": "50"、 "Y": "50"、 "幅": "1200"、 "高さ": "200"、 "最大化": "false" }

答えて

2

xとyの値は数字ではなく文字列です。

は次のようになります。

"x":50 

最大化は、文字列ではないブール値です。

関連する問題