angular - Angular 应用程序在电子中打开,但不在浏览器中
问题描述
在我声明的 main.js 文件中:
webPreferences: {
nodeIntegration: true
}
所以,我可以在电子中打开应用程序,但在浏览器中我有一个错误:
TypeError: window.require is not a function
在我的组件中,我遇到了 require electron 错误,现在我使用:
declare var window: Window;
declare global {
interface Window {
process: any;
require: any;
}
}
const electron = window.require('electron');
我尝试了很多方法,但是浏览器无法识别window.require函数。
解决方案
推荐阅读
- google-apps-script - 使用 Google Appscript 和 Google Sheet 发送多个附件
- model - 我如何获得 ARIMA 模型的置信区间值?
- python - 如何仅使用一个 for 循环将三个列表理解合并为一个?
- node.js - 如何在节点中模拟 SQL Server 连接池
- java - 如何将命令行参数传递给 IntelliJ 本身,以改变 IDE(不是我自己在 IDE 中的应用程序)的行为?
- android - 在 Kotlin 中使用 Android 中的 Multipart 和 Request Body 将图像上传到服务器
- python - 在python中如何从root用户获取普通用户名?
- android - Volley 并行 API 调用可能吗?
- angular - Angular中特定模式的字母数字字符串格式
- rust - 在循环中生锈的 & 在做什么?