Wkhtmltopdf修补了angularjs的QT问题

Nan*_*com 2 wkhtmltopdf angularjs

使用修补的Qt运行任何版本的wkhtmltopdf时出现此JavaScript错误:

Warning: undefined:0 Error: [$injector:modulerr] Failed to instantiate module ng due to:
'undefined' is not an object
http://errors.angularjs.org/1.5.7/$injector/modulerrp0=ng&p1='undefined'%20is%20not%20an%20object
Run Code Online (Sandbox Code Playgroud)

(我正在尝试使用angularjs 1.5渲染页面).

当我使用wkhtmltopdf的版本没有修补Qt我没有得到错误,一切正常.

我使用这个heroku buildpack,用修补的Qt安装版本0.12.3,我收到了这个错误.

知道怎么解决我的问题吗?我可能会在没有修补Qt的情况下安装wkhtmltopdf,但似乎我必须编译它...

Nan*_*com 7

我终于设法使它适用于所有版本:我需要特殊版本的.bind()JavaScript函数polyfill:

var isFunction = function (o) {
return typeof o == 'function';
};

var bind,
slice = [].slice,
proto = Function.prototype,
featureMap;

featureMap = {
'function-bind': 'bind'
};

function has(feature) {
  var prop = featureMap[feature];
  return isFunction(proto[prop]);
}

// check for missing features
if (!has('function-bind')) {
  // adapted from Mozilla Developer Network example at
  // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind
  bind = function bind(obj) {
    var args = slice.call(arguments, 1),
      self = this,
      nop = function() {
      },
      bound = function() {
        return self.apply(this instanceof nop ? this : (obj || {}), args.concat(slice.call(arguments)));
      };
    nop.prototype = this.prototype || {}; // Firefox cries sometimes if prototype is undefined
    bound.prototype = new nop();
    return bound;
  };
  proto.bind = bind;
}
Run Code Online (Sandbox Code Playgroud)