Integrate jQuery into a electron app

后端 未结 3 1417
臣服心动
臣服心动 2021-02-09 16:41

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:33

    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.

    
    

提交回复
热议问题