<!-- 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>
Benefits
- Works for both browser and electron with the same code
- Fixes issues for ALL 3rd-party libraries (not just jQuery) without having to specify each one
- Script Build / Pack Friendly (i.e. Grunt / Gulp all scripts into vendor.js)
- Does NOT require
node-integrationto be false
source here
本文介绍了一种在浏览器和Electron环境中通用的模块加载策略,该策略解决了第三方库(如jQuery)的兼容性问题,无需单独配置,同时支持脚本打包,如使用Grunt或Gulp将所有脚本整合到vendor.js中。
213

被折叠的 条评论
为什么被折叠?



