2017-04-15 89 views
0

這是在Electron中創建窗口的標準方式(來自文檔);如何在瀏覽器窗口中加載JavaScript?

let win; 
function createWindow(){ 
    // Create the browser window. 
    win = new BrowserWindow({width: 680, height: 420, frame: false, transparent: true, show: false}); 

    // and load the index.html of the app. 
    win.loadURL(url.format({ 
    pathname: path.join(__dirname, 'test.html'), 
    protocol: 'file:', 
    slashes: true 
    })); 

    win.once('ready-to-show', function() { 
    win.show(); 
    }); 


    // Open the DevTools. 
    // win.webContents.openDevTools() 

    // Emitted when the window is closed. 
    win.on('closed', function() { 
    // Dereference the window object, usually you would store windows 
    // in an array if your app supports multi windows, this is the time 
    // when you should delete the corresponding element. 
    win = null; 
    }) 

} 

工作正常,但我怎麼可以加載了一堆的JavaScript文件,如jQuery等,在窗口範圍內沒有使用的test.html標籤<script>

的原因,我不希望使用腳本標記是因爲我可以有很多的.js文件和.html文件,我不想更新HTML每次有新的變化。我寧願讓它們在創建窗口的函數中。在文檔

回答