【问题标题】:fs.existsSync is not a function error in Angular & Electron appfs.existsSync 不是 Angular 和 Electron 应用程序中的函数错误
【发布时间】:2018-03-11 03:11:43
【问题描述】:

我正在使用 Electron 和 Angular 4 开发应用程序。我想在单击按钮以选择文件夹时显示一个对话框,但 electron API 存在问题:

我见过很多人有同样的问题,但我找不到解决这个问题的方法。我试图通过添加一个需要 fs 模块的脚本来修改 angular-cli 配置,但它也失败了......

我的组件如下所示:

import { Component, OnInit } from '@angular/core';
import { dialog } from 'electron';

@Component({
  selector: 'app-photos',
  templateUrl: './photos.component.html'
})
export class PhotosComponent implements OnInit {

  private path = '';
  private photos = ['A', 'B', 'C'];

  constructor() { }

  ngOnInit() {
  }

  openFolderSelector() {
    dialog.showOpenDialog({ properties: ['openDirectory'] }, (filepaths) => {
      console.log(filepaths);
    });
  }
}

有人成功了吗?

感谢您的帮助!

【问题讨论】:

标签: angular web-applications electron desktop fs


【解决方案1】:

尝试像这样导入“对话”?

const { dialog } = require('electron');

Source

【讨论】:

    猜你喜欢
    • 2016-06-11
    • 2019-12-27
    • 1970-01-01
    • 2017-08-23
    • 1970-01-01
    • 2021-06-17
    • 2020-08-12
    • 1970-01-01
    • 2018-11-30
    相关资源
    最近更新 更多