Ich versuche, einen einzeiligen Code in Javascript zu verstehen, aber es ist nicht sehr offensichtlich.Konvertieren Sie eine JavaScript-Zeile in besser lesbaren Code
Die Linie, die funktioniert:
this._iconNeedsUpdate = !0,this._expandBounds(t), t instanceof L.MarkerCluster ? (e || (this._childClusters.push(t), t.__parent = this), this._childCount += t._childCount) : (e || this._markers.push(t), this._childCount++), this.__parent && this.__parent._addChild(t, !0)
ich unten mit Code zu konvertieren versucht, aber es funktioniert nicht:
this._iconNeedsUpdate = !0;
this._expandBounds(t);
if (t instanceof L.MarkerCluster) {
if (!e) {
this._childClusters.push(t);
t.__parent = this;
} else {
this._childCount += t._childCount;
}
} else {
if (!e) {
this._markers.push(t);
this._childCount++;
}
}
if (this.__parent) {
this.__parent._addChild(t, !0);
}
Jede Idee?
Danke!
Nach Ihrer Hilfe der gute Code ist:
this._iconNeedsUpdate = true;
this._expandBounds(t);
if (t instanceof L.MarkerCluster) {
if (!e) {
this._childClusters.push(t);
t.__parent = this;
}
this._childCount += t._childCount
} else {
if (!e) {
this._markers.push(t);
}
this._childCount++;
}
if (this.__parent) {
this.__parent._addChild(t, true);
}
Thank you!
I 6 verschiedene JavaScript-Konzepte in den ersten drei Zeilen des erweiterten Code gezählt haben. Was genau verstehst du nicht darüber? – Quentin
Das [Verschlüsselung] Tag auf dieser Frage bringt mich zum Lachen. –
Also die verkleinerte Version funktioniert aber die erweiterte nicht? Ist das das Problem? (Bitte klären Sie die Frage) – SparK