Electron: jQuery is not defined

前端 未结 19 2744
我在风中等你
我在风中等你 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:51

    If you are using Angular2 you can create a new js file with this code:

    // jquery-electron.js
    
    if ((!window.jQuery || !window.$) && (!!module && !!module.exports)) {
          window.jQuery = window.$ = module.exports;
    }
    

    and put it right after jquery path, in .angular-cli.json:

    "scripts": [
        "../node_modules/jquery/dist/jquery.js",
        "assets/js/jquery-electron.js",
        ...
        ...
    ]
    

提交回复
热议问题