phantomjs 自定义 header 问题请教

我在外部变量 title = "标题"

            var title ="标题"
            var config = {
                width: "1040px",
                height: "1414px",
                borderLeft: "5px solid #000",
                margin: {
                    top: "0px",
                    left: "15px",
                    right: "5px",
                    bottom: "0px"
                },
                orientation: "portrait",
                header: {
                    height: 315,
                    contents: phInstance.callback(function(page, num) {
                    //这里的 title 获取不到 
                    return title;
                })
                },
                footer: {
                    height: 50,
                    contents: phInstance.callback(function(pageNum, numPages) {
                        return "<div style='border-top:8px dashed #000'></div><p style='text-align:center;'>底部" + pageNum + "/" + numPages + "</p>";
                    })
                }
            }

报错信息

info: undefined:1 in render
info: phantomjs://code/shim.js:191 in executeCommand
info: phantomjs://code/shim.js:141 in read
info: SyntaxError: Unexpected EOF

请教下使用过的朋友 我这块怎么去设置自定义标题

阅读 3.6k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题