Entschuldigung im Voraus, ich bin sehr neu zu Reagieren.Zugriff auf "this" in reagieren beim Zuweisen von Methode zu einem Ereignis
In printDocument
Ich gründe die oHiddFrame.onload = this.setPrint;
sogar this.setPrint
aber einen Fehler von Cannot set property '__container__' of undefined
für this
in setPrint
auf der ersten Zuordnung bin immer.
I onClick={this.printDocument.bind(null, this.props.document.view_href)}
auf die Schaltfläche in machen bin Einstellung(). Wie verbinde ich "this" mit dem tatsächlichen Ereignis, dem ich es zuweise?
Vielen schätzen jede Hilfe oder Beratung.
closePrint: function() {
document.body.removeChild(this.oHiddFrame.__container__);
},
setPrint: function() {
this.contentWindow.__container__ = this;
this.contentWindow.onbeforeunload = this.closePrint;
this.contentWindow.onafterprint = this.closePrint;
this.contentWindow.focus();
this.contentWindow.print();
},
printDocument: function (url) {
var oHiddFrame = document.createElement("iframe");
oHiddFrame.onload = this.setPrint;
oHiddFrame.style.visibility = "hidden";
oHiddFrame.style.position = "fixed";
oHiddFrame.style.right = "0";
oHiddFrame.style.bottom = "0";
oHiddFrame.src = url;
document.body.appendChild(oHiddFrame);
},