2017-04-15 49 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每次有新的变化。我宁愿让它们在创建窗口的函数中。在文档

回答

相关问题