未验证 提交 0aaad744 编写于 作者: K king_he 提交者: Gitee

update en/application-dev/reference/apis/js-apis-url.md.

Signed-off-by: Nking_he <6384784@qq.com>
上级 cc8a63a1
# URL String Parsing
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**<br>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -25,9 +25,9 @@ Creates a **URLSearchParams** instance.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| init | string[][]&nbsp;\|&nbsp;Record&lt;string,&nbsp;string&gt;&nbsp;\|&nbsp;string&nbsp;\|&nbsp;URLSearchParams | No| Input parameter objects, which include the following:<br>- **string[][]**: two-dimensional string array<br>- **Record&lt;string,&nbsp;string&gt;**: list of objects<br>- **string**: string<br>- **URLSearchParams**: object|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| init | string[][]&nbsp;\ |&nbsp;Record&lt;string,&nbsp;string&gt;&nbsp;\ |&nbsp;string&nbsp;\ |&nbsp;URLSearchParams | No | Input parameter objects, which include the following:<br>- **string[][]**: two-dimensional string array<br>- **Record&lt;string,&nbsp;string&gt;**: list of objects<br>- **string**: string<br>- **URLSearchParams**: object |
**Example**
......@@ -48,10 +48,10 @@ Appends a key-value pair into the query string.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Key of the key-value pair to append.|
| value | string | Yes| Value of the key-value pair to append.|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| name | string | Yes | Key of the key-value pair to append. |
| value | string | Yes | Value of the key-value pair to append. |
**Example**
......@@ -70,9 +70,9 @@ Deletes key-value pairs of the specified key.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Key of the key-value pairs to delete.|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| name | string | Yes | Key of the key-value pairs to delete. |
**Example**
......@@ -91,15 +91,15 @@ Obtains all the key-value pairs based on the specified key.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Key specified to obtain all key-value pairs.|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| name | string | Yes | Key specified to obtain all key-value pairs. |
**Return value**
| Type| Description|
| -------- | -------- |
| string[] | All key-value pairs matching the specified key.|
| Type | Description |
| -------- | -------- |
| string[] | All key-value pairs matching the specified key. |
**Example**
......@@ -119,9 +119,9 @@ Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and th
**Return value**
| Type| Description|
| -------- | -------- |
| IterableIterator&lt;[string,&nbsp;string]&gt; | ES6 iterator.|
| Type | Description |
| -------- | -------- |
| IterableIterator&lt;[string,&nbsp;string]&gt; | ES6 iterator. |
**Example**
......@@ -141,18 +141,18 @@ Traverses the key-value pairs in the **URLSearchParams** instance by using a cal
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked to traverse the key-value pairs in the **URLSearchParams** instance.|
| thisArg | Object | No| Value to use when the callback is invoked.|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| callbackfn | function | Yes | Callback invoked to traverse the key-value pairs in the **URLSearchParams** instance. |
| thisArg | Object | No | Value to use when the callback is invoked. |
**Table 1** callbackfn parameter description
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | string | Yes| Value that is currently traversed.|
| key | string | Yes| Key that is currently traversed.|
| searchParams | Object | Yes| Instance that invokes the **forEach** method.|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| value | string | Yes | Value that is currently traversed. |
| key | string | Yes | Key that is currently traversed. |
| searchParams | Object | Yes | Instance that invokes the **forEach** method. |
**Example**
......@@ -172,16 +172,16 @@ Obtains the value of the first key-value pair based on the specified key.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Key specified to obtain the value.|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| name | string | Yes | Key specified to obtain the value. |
**Return value**
| Type| Description|
| -------- | -------- |
| string | Returns the value of the first key-value pair if obtained.|
| null | Returns null if no value is obtained.|
| Type | Description |
| -------- | -------- |
| string | Returns the value of the first key-value pair if obtained. |
| null | Returns null if no value is obtained. |
**Example**
......@@ -201,15 +201,15 @@ Checks whether a key has a value.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Key specified to search for its value.|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| name | string | Yes | Key specified to search for its value. |
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the value exists; returns **false** otherwise.|
| Type | Description |
| -------- | -------- |
| boolean | Returns **true** if the value exists; returns **false** otherwise. |
**Example**
......@@ -228,10 +228,10 @@ Sets the value for a key. If key-value pairs matching the specified key exist, t
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Key of the value to set.|
| value | string | Yes| Value to set.|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| name | string | Yes | Key of the value to set. |
| value | string | Yes | Value to set. |
**Example**
......@@ -267,9 +267,9 @@ Obtains an ES6 iterator that contains the keys of all the key-value pairs.
**Return value**
| Type| Description|
| -------- | -------- |
| IterableIterator&lt;string&gt; | ES6 iterator that contains the keys of all the key-value pairs.|
| Type | Description |
| -------- | -------- |
| IterableIterator&lt;string&gt; | ES6 iterator that contains the keys of all the key-value pairs. |
**Example**
......@@ -289,9 +289,9 @@ Obtains an ES6 iterator that contains the values of all the key-value pairs.
**Return value**
| Type| Description|
| -------- | -------- |
| IterableIterator&lt;string&gt; | ES6 iterator that contains the values of all the key-value pairs.|
| Type | Description |
| -------- | -------- |
| IterableIterator&lt;string&gt; | ES6 iterator that contains the values of all the key-value pairs. |
**Example**
......@@ -312,9 +312,9 @@ Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and th
**Return value**
| Type| Description|
| -------- | -------- |
| IterableIterator&lt;[string,&nbsp;string]&gt; | ES6 iterator.|
| Type | Description |
| -------- | -------- |
| IterableIterator&lt;[string,&nbsp;string]&gt; | ES6 iterator. |
**Example**
......@@ -335,9 +335,9 @@ Obtains search parameters that are serialized as a string and, if necessary, per
**Return value**
| Type| Description|
| -------- | -------- |
| string | String of serialized search parameters, which is percent-encoded if necessary.|
| Type | Description |
| -------- | -------- |
| string | String of serialized search parameters, which is percent-encoded if necessary. |
**Example**
......@@ -354,20 +354,20 @@ console.log(params.toString());
### Attributes
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| hash | string | Yes| Yes| String that contains a harsh mark (#) followed by the fragment identifier of a URL.|
| host | string | Yes| Yes| Host information in a URL.|
| hostname | string | Yes| Yes| Hostname (without the port) in a URL.|
| href | string | Yes| Yes| String that contains the whole URL.|
| origin | string | Yes| No| Read-only string that contains the Unicode serialization of the origin of the represented URL.|
| password | string | Yes| Yes| Password in a URL.|
| pathname | string | Yes| Yes| Path in a URL.|
| port | string | Yes| Yes| Port in a URL.|
| protocol | string | Yes| Yes| Protocol in a URL.|
| search | string | Yes| Yes| Serialized query string in a URL.|
| searchParams | URLsearchParams | Yes| No| **URLSearchParams** object allowing access to the query parameters in a URL.|
| username | string | Yes| Yes| Username in a URL.|
| Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- |
| hash | string | Yes | Yes | String that contains a harsh mark (#) followed by the fragment identifier of a URL. |
| host | string | Yes | Yes | Host information in a URL. |
| hostname | string | Yes | Yes | Hostname (without the port) in a URL. |
| href | string | Yes | Yes | String that contains the whole URL. |
| origin | string | Yes | No | Read-only string that contains the Unicode serialization of the origin of the represented URL. |
| password | string | Yes | Yes | Password in a URL. |
| pathname | string | Yes | Yes | Path in a URL. |
| port | string | Yes | Yes | Port in a URL. |
| protocol | string | Yes | Yes | Protocol in a URL. |
| search | string | Yes | Yes | Serialized query string in a URL. |
| searchParams | URLsearchParams | Yes | No | **URLSearchParams** object allowing access to the query parameters in a URL. |
| username | string | Yes | Yes | Username in a URL. |
### constructor
......@@ -379,10 +379,10 @@ Creates a URL.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| url | string | Yes| Input object.|
| base | string&nbsp;\|&nbsp;URL | No| Input parameter, which can be any of the following:<br>- **string**: string<br>- **URL**: string or object|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| url | string | Yes | Input object. |
| base | string&nbsp;\ |&nbsp;URL | No | Input parameter, which can be any of the following:<br>- **string**: string<br>- **URL**: string or object |
**Example**
......@@ -410,9 +410,9 @@ Converts the parsed URL into a string.
**Return value**
| Type| Description|
| -------- | -------- |
| string | Website address in a serialized string.|
| Type | Description |
| -------- | -------- |
| string | Website address in a serialized string. |
**Example**
......@@ -431,12 +431,12 @@ Converts the parsed URL into a JSON string.
**Return value**
| Type| Description|
| -------- | -------- |
| string | Website address in a serialized string.|
| Type | Description |
| -------- | -------- |
| string | Website address in a serialized string. |
**Example**
```js
const url = new URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toJSON()
```
```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册