Methode Beschreibung:
Konvertieren Sie ein Parsen -URL -Objekt in eine formatierte URL -Zeichenfolge.
Grammatik:
Die Codekopie lautet wie folgt:
url.format (urlobj)
Parameter empfangen:
URLOBJ repräsentiert ein URL -Objekt und kann die folgenden Eigenschaften enthalten: (kann mit Beispielen verglichen werden)
href vollen Weg
Protokolisprotokoll (wie http: //)
Auth
Hostname Hostname
Port Port
Host Host (Hostname + Port)
Pathname '/' kann als Verzeichnis verstanden werden
Abfrageparameterliste
Suchabfragebedingungen (dh die Parameterliste mit "?")
Hash -Hash -Wert
Beispiel:
Die Codekopie lautet wie folgt:
var url = erfordern ('url');
var a = url.format ({{
Protokoll: 'Http',
AUTH: NULL,
Host: 'Beispiel.com:8080',
Port: '8080',
Hostname: 'Beispiel.com',
Hash: Null,
Suche: '? a = index & t = article & m = Standard',
Abfrage: 'a = Index & t = Artikel & M = Standard',
Pfadname: '/eins',
Pfad: '/ein? a = index & t = article & m = Standard',
href: 'http://example.com:8080/one?a=Index&t=Article&m=default'
});
console.log (a);
// Ausgabeergebnis: http://example.com:8080/one?a=Index&t=Article&m=default