Electron不支持 jquery ,angularjs解决办法

Electron 在运行环境中引入了 Node.js,默认启用了Node.js的require模块,而这些框架为了支持commondJS标准,当Window中存在require时,会启用模块引入的方式。所以在 DOM 中有一些额外的变量,比如module、exports和require。这导致了许多库不能正常运行,因为它们也需要将同名的变量加入运行环境中。

解决方案,Electron中删除这些变量

复制代码
if (typeof process !== "undefined" && process.versions && process.versions.electron) {
  console.log("Running in Electron!");
  // 重命名 Electron 提供的 require
  window.nodeRequire = require;

  delete window.require;

  delete window.exports;

  delete window.module;
} else {
  console.log("Running in Chrome!");
}
```
相关推荐
卸任2 天前
Electron自制翻译工具:增加中英互译
前端·react.js·electron
皓子3 天前
海狸IM桌面端:AI辅助开发的技术架构实践
前端·electron·ai编程
QQ_hoverer3 天前
前端使用 preview 插件预览docx文件
前端·javascript·layui·jquery
crary,记忆3 天前
Angular报错:cann‘t bind to ngClass since it is‘t a known property of div
前端·javascript·angular·angular.js
xiaobangsky5 天前
Electron桌面应用下,在拍照、展示pdf等模块时,容易导致应用白屏
javascript·electron
WHOAMI_老猫5 天前
渗透实战PortSwigger Labs AngularJS DOM XSS利用详解
前端·渗透测试·xss·angular.js
就是我5 天前
Electron多窗口应用实战
前端·javascript·electron
我怎么能这么帅气5 天前
从“文件失踪案”说起:Electron 中 getAppPath 和 getPath 的妙用
前端·javascript·electron
xianshenglu6 天前
我的 Angular 总结:一些让我惊讶的 NGRX 行为
前端·javascript·angular.js
界面开发小八哥7 天前
Telerik生态整合:Kendo UI for Angular组件在WinForms应用中的深度嵌入(一)
ui·界面控件·kendo ui·angular.js·ui开发·telerik