Electron: jQuery is not defined

前端 未结 19 2943
我在风中等你
我在风中等你 2020-11-22 06:20

Problem: while developing using Electron, when you try to use any JS plugin that requires jQuery, the plugin doesn\'t find jQuery, even if you load in the correct path using

19条回答
  •  忘掉有多难
    2020-11-22 06:55

    electron FAQ answer :

    http://electron.atom.io/docs/faq/

    I can not use jQuery/RequireJS/Meteor/AngularJS in Electron.

    Due to the Node.js integration of Electron, there are some extra symbols inserted into the DOM like module, exports, require. This causes problems for some libraries since they want to insert the symbols with the same names.

    To solve this, you can turn off node integration in Electron:

    // In the main process.

    let win = new BrowserWindow({  
     webPreferences: {
     nodeIntegration: false   } });
    

    But if you want to keep the abilities of using Node.js and Electron APIs, you have to rename the symbols in the page before including other libraries:

     
     
     
    
    

提交回复
热议问题