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!");
}
```
相关推荐
薛定猫AI2 天前
【深度解析】Gemma Chat 本地 AI 编程 Agent:Electron + MLX + 开源模型的离线 Vibe Coding 实战
javascript·人工智能·electron
多秋浮沉度华年3 天前
electron 初始使用记录
javascript·arcgis·electron
阿波罗尼亚3 天前
桌面应用开发技术:NetBeans RCP / Eclipse RCP / JavaFX / Electron / Qt / Flutter Deskto
java·eclipse·electron
Cyan_RA93 天前
SpringMVC REST 详解
java·spring·mvc·springmvc·restful·jquery·jsp
web打印社区3 天前
2026最新Web静默打印解决方案,无插件无预览,完美替代Lodop
前端·javascript·vue.js·electron·pdf
垚森3 天前
VibePlayer v1.3.3 更新:全新 Logo + 修复音乐库高亮 Bug
ai·electron
一叶飘零晋3 天前
【(一)Electron 使用之如何用vite+vue3搭建初始框架】
前端·javascript·electron
天天进步20154 天前
魔音漫创源码解析:架构总览:Electron 30 + React 18 + Zustand,构建桌面级影视生产工具
react.js·架构·electron
一叶飘零晋4 天前
【(二)Electron 使用之常用技巧】
javascript·electron·ecmascript
shmily麻瓜小菜鸡4 天前
在 VSCode 里遇到报红是因为 Angular 编译器无法识别
ide·vscode·angular.js