我正在使用python
和django
在jQuery
jsTree
中构建一个应用程序。该应用程序在浏览器上正常运行,但是当我为我的项目创建 Electron 应用程序时,它表明
我收到此错误
Uncaught Error: Cannot find module 'jquery'
at Module._resolveFilename (module.js:485:15)
at Function.Module._resolveFilename (/usr/local/lib/node_modules/electron/dist/resources/electron.asar/common/reset-search-paths.js:35:12)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at http://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.5/jstree.min.js:2:146
at http://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.5/jstree.min.js:2:175
我还在jquery CDN链接之后包含了以下脚本。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
try {
$ = jQuery = module.exports;
} catch(e) {}
</script>
最佳答案
找到了答案
<!-- Insert this line above script imports -->
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
<!-- normal script imports etc -->
<script src="scripts/jquery.min.js"></script>
<script src="scripts/vendor.js"></script>
<!-- Insert this line after script imports -->
<script>if (window.module) module = window.module;</script>
引用:Electron: jQuery is not defined
关于javascript - $(…).jstree不是函数,在Electron js中使用JSTree,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52381131/