Integrate jQuery into a electron app

后端 未结 3 1689
灰色年华
灰色年华 2021-02-09 16:49

I\'m trying to add jquery functionality to a desktop app written in electron Using the electron-quick-start repo i\'m adding the downloaded jquery file to the main.html

3条回答
  •  情话喂你
    2021-02-09 17:38

    When you call require inside index.js, or the main process, it's looking for the node module. So you'll need to install jQuery via npm and save it as a dependency in your apps package.json file.

    npm install jquery --save
    

    Then your index.js should theoretically see it just fine using

    let $ = require('jquery');
    mainWindow.$ = $;
    

    Refer to the Node.JS section for installing jQuery. This is what Electron uses.

    --

    OLD ANSWER

    Inside your main.html, just include the JavaScript like you would any traditional JS file.

    
    

提交回复
热议问题