我正在尝试在 phantomjs 示例中创建自定义页脚:https ://github.com/ariya/phantomjs/blob/master/examples/printheaderfooter.js
这是我的代码:
var phantom = require('node-phantom');
phantom.create(function (err, ph) {
ph.createPage(function (err, page) {
page.set('paperSize', {
format: 'A4',
orientation: 'portrait',
footer: {
contents: ph.callback(function (pageNum, numPages) {
if (pageNum == 1) {
return "";
}
return "<h1>Header <span style='float:right'>" + pageNum + " / " + numPages + "</span></h1>";
})
}
}, function () {
page.open('http://www.google.com', function () {
})
})
})
});
但不幸的是,我收到以下错误:
TypeError: Object #<Object> has no method 'callback';
ph 不公开回调方法是错误吗?