javascript 如何让 Phantomjs 在 Windows 上执行一个 js 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12551218/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to have Phantomjs execute a js file on Windows
提问by Ricky
I just executed phantomjs.exe and a command line window popup. How could I execute the .js files under ./examples/? If just enter the file name "version.js", I got the error message - "cannot find the variable: version".
我刚刚执行了 phantomjs.exe 和一个命令行窗口弹出窗口。我如何执行 ./examples/ 下的 .js 文件?如果只是输入文件名“version.js”,我会收到错误消息-“找不到变量:版本”。
Thank you!
谢谢!
回答by DeadAlready
Open the command window - this can be done by holding SHIFT + Right mouse click and there is a choice of Open command window here...
打开命令窗口 - 这可以通过按住 SHIFT + 鼠标右键单击来完成,并且可以选择在此处打开命令窗口...
From the command line you can then invoke the phantomjs.exe
然后您可以从命令行调用 phantomjs.exe
$ path/to/phantomjs.exe path/to/version.js
回答by Dipesh
You can also create windows environment path variable
您还可以创建 windows 环境路径变量
add path/to/phantomjs.exeas environment variable with name phantomjs
添加path/to/phantomjs.exe作为名为phantomjs 的环境变量
then From the command line you can then invoke the phantomjs
然后从命令行你可以调用phantomjs
$ phantomjs path/to/version.js
回答by LeGeekDOzoZoo
A better answer (I think) is : Add the path to the folder containing phantomjs.exe, to the PATH environment variable :) on Windows.
更好的答案(我认为)是:在 Windows 上将包含 phantomjs.exe 的文件夹的路径添加到 PATH 环境变量:)。