angular - Angular Electron 从组件调用服务(类型错误:getSources 不是函数)
问题描述
我正在使用 Angular 12 和电子。
我在服务中有一个方法,如下所示:
在我的服务中:
const desktopCapturer = (window as any).require('electron');
...
getDesktopCaptureSources(options: any) {
return new Promise((resolve, reject) => {
desktopCapturer.getSources(options).then((sources: any[]) => {
return resolve(sources.map(source => {
return {
id: source.id,
name: source.name,
url: source.thumbnail.toDataURL()
};
}));
});
});
}
在我的组件上,我正在调用该方法来尝试获取一些输出:
screenshot() {
let options = { types: ['screen'], thumbnailSize: 200 };
console.log(this.electronService.getDesktopCaptureSources(options));
}
但控制台只是返回:
ERROR Error: Uncaught (in promise): TypeError: eE.getSources is not a function
TypeError: eE.getSources is not a function
我怎样才能解决这个问题?
解决方案
推荐阅读
- java - 我正在使用 jsp ajax 向 servlet 发送表单数据,但是 ajax 响应在纳秒内消失
- flutter - 我可以使用 Google 表格作为我的移动应用程序的数据源吗
- javascript - 在选择正确的画布时如何执行 addEventListener 函数?
- c - 如何在c中将形式for循环切换为while循环?
- .htaccess - .htaccess 将子目录重定向到新域
- excel - 在线检索货币汇率
- arrays - 无法在 C 中使用数组构造堆栈
- c# - 我想在侧面导航栏 blazor C# 中分层显示类别
- c++ - 如何防止 CreateProcess/ShellExecute 重置 Windows 空闲计时器?
- powershell - Powershell在forloop中访问具有多个属性的XML节点