Som*_*der 8 javascript node.js electron
我正在使用NodeJS/Electron作为桌面应用.
我想做的是用它的OS'默认应用程序打开一个文件,比如.docx和Word.
到目前为止我尝试的是使用child_process.spawn,.exec或.execFile的方法,但我没有得到任何东西.
这是我的实际代码:
var fs = require('fs'),
cp = require('child_process');
cp.spawn(__dirname + '/test.docx');
Run Code Online (Sandbox Code Playgroud)
提前致谢.
Vad*_*gon 17
使用openItem()Electron shell模块提供的功能,例如:
const shell = require('electron').shell;
const path = require('path');
shell.openItem(path.join(__dirname, 'test.docx'));
Run Code Online (Sandbox Code Playgroud)
根据文档,shell模块应该在主/浏览器和渲染器进程中都可用.
| 归档时间: |
|
| 查看次数: |
7273 次 |
| 最近记录: |