return 评估 javascript 函数到终端
return evaluated javascript function to terminal
我正在尝试 return 一个已经计算到终端的函数。我尝试使用 window.onload()
、console.log();
alert();
但 URL 未被评估并发送到终端。
I 运行 下面的代码使用命令 phantomjs test.js
var webPage = require('webpage');
var page = webPage.create();
function testlink() {
return(["h","t","t","p","s",":","\/","\/","i","b","m",".","c","o","m"]);
}
window.onload = testlink;
console.log(testlink);
alert(testlink);
而不是得到(这就是我想要的)
https://ibm.com
我明白了
function testlink() {
return(["h","t","t","p","s",":","\/","\/","i","b","m",".","c","o","m"]);
}
Ps:我正在使用 Ubuntu 18.04 和 phantomjs 2.1.1
尝试 console.log(testlink())
而不是 console.log(testlink)
如果我们想连接该数组中的所有字符,只需 return:
["h","t","t","p","s",":","\/","\/","i","b","m",".","c","o","m"].join("")
或者如果您不想更改函数,请执行 console.log(testlink().join(""))
我正在尝试 return 一个已经计算到终端的函数。我尝试使用 window.onload()
、console.log();
alert();
但 URL 未被评估并发送到终端。
I 运行 下面的代码使用命令 phantomjs test.js
var webPage = require('webpage');
var page = webPage.create();
function testlink() {
return(["h","t","t","p","s",":","\/","\/","i","b","m",".","c","o","m"]);
}
window.onload = testlink;
console.log(testlink);
alert(testlink);
而不是得到(这就是我想要的)
https://ibm.com
我明白了
function testlink() {
return(["h","t","t","p","s",":","\/","\/","i","b","m",".","c","o","m"]);
}
Ps:我正在使用 Ubuntu 18.04 和 phantomjs 2.1.1
尝试 console.log(testlink())
而不是 console.log(testlink)
如果我们想连接该数组中的所有字符,只需 return:
["h","t","t","p","s",":","\/","\/","i","b","m",".","c","o","m"].join("")
或者如果您不想更改函数,请执行 console.log(testlink().join(""))