我有一个应该在创建目录后打开目录的功能,
setTimeout(function()
{
var fs = require('fs');
console.log(newPath);
var open = fs.opensync(newPath, 'r');
}, 2500);
但这似乎不起作用。我收到以下错误
首先是
TypeError:undefined不是eval的函数(eval位于
<anonymous>
(file:///Users/proslav/Library/Developer/Xcode/DerivedData/trackingCore-ecxfviftqracjxhimcuhhhvyddso/Build/Products/Debug/trackingCore.app/Contents/Resources/timeBroFront。 app / Contents / Resources / app.nw / js / jquery-1.10.2.min.js:3:4994)::43:18)
其次是
未捕获的ReferenceError:未定义require
我以为可能是我的变量newpath
未定义,但日志显示了正确的链接。创建目录的var fs = require('fs');
工作正常。
我在这里做错了什么?
我发现了该怎么做。Node-webkit为此提供了一个功能。它在MAC上运行,也应该在Windows上运行。下面的函数是一个示例函数。nw.gui
并gui.Shell.showItemInFolder
做了事情对我来说。输入的Thx。
/*---------
Open Folder
---------*/
function openFolder(path){
var gui = require('nw.gui');
gui.Shell.showItemInFolder(path);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句