提交 9f5af2a2 编写于 作者: G Gloria

Update docs against 11985+12023+12047+12134

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 5fc39b85
# Device Usage Statistics
# @ohos.deviceUsageStatistics (Device Usage Statistics)
This module provides APIs for collecting statistics on device usage.
......@@ -487,7 +487,7 @@ Enumerates the interval types for querying the application usage duration.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
| Name | Default Value | Description |
| Name | Value | Description |
| ------------ | ---- | ---------------------------------------- |
| BY_OPTIMIZED | 0 | The system obtains the application usage duration statistics in the specified time frame at the interval the system deems appropriate.|
| BY_DAILY | 1 | The system obtains the application usage duration statistics in the specified time frame on a daily basis. |
......
# Obtaining Process Information
# @ohos.process (Obtaining Process Information)
> **NOTE**
>
......@@ -18,13 +18,13 @@ import process from '@ohos.process';
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| egid | number | Yes| No| Effective group identifier (EGID) of a process. This is a system API and cannot be called by third-party applications.|
| euid | number | Yes| No| Effective user identifier (EUID) of a process. This is a system API and cannot be called by third-party applications.|
| gid | number | Yes| No| Group identifier (GID) of a process. This is a system API and cannot be called by third-party applications.|
| egid | number | Yes| No| Effective group identifier (EGID) of a process.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| euid | number | Yes| No| Effective user identifier (EUID) of a process.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| gid | number | Yes| No| Group identifier (GID) of a process.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| uid | number | Yes| No| User identifier (UID) of a process.|
| groups | number[] | Yes| No| Array with supplementary group IDs. This is a system API and cannot be called by third-party applications.|
| groups | number[] | Yes| No| Array with supplementary group IDs.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| pid | number | Yes| No| Process ID (PID) of a process.|
| ppid | number | Yes| No| Parent process ID (PPID) of a process. This is a system API and cannot be called by third-party applications.|
| ppid | number | Yes| No| Parent process ID (PPID) of a process.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| tid<sup>8+</sup> | number | Yes| No| Thread ID (TID) of a process.|
......@@ -32,7 +32,7 @@ import process from '@ohos.process';
Provides APIs for throwing exceptions during the addition of a process.
### process.isAppUid<sup>9+</sup>
### isAppUid<sup>9+</sup>
isAppUid(v: number): boolean
......@@ -60,7 +60,7 @@ let result = pro.isAppUid(688);
```
### process.getUidForName<sup>9+</sup>
### getUidForName<sup>9+</sup>
getUidForName(v: string): number
......@@ -88,7 +88,7 @@ let pres = pro .getUidForName("tool");
```
### process.getThreadPriority<sup>9+</sup>
### getThreadPriority<sup>9+</sup>
getThreadPriority(v: number): number
......@@ -117,7 +117,7 @@ let pres = pro.getThreadPriority(tid);
```
### process.getSystemConfig<sup>9+</sup>
### getSystemConfig<sup>9+</sup>
getSystemConfig(name: number): number
......@@ -146,7 +146,7 @@ let pres = pro.getSystemConfig(_SC_ARG_MAX);
```
### process.getEnvironmentVar<sup>9+</sup>
### getEnvironmentVar<sup>9+</sup>
getEnvironmentVar(name: string): string
......@@ -174,7 +174,7 @@ let pres = pro.getEnvironmentVar("PATH");
```
### process.exit<sup>9+</sup>
### exit<sup>9+</sup>
exit(code: number): void
......@@ -198,7 +198,7 @@ pro.exit(0);
```
### process.kill<sup>9+</sup>
### kill<sup>9+</sup>
kill(signal: number, pid: number): boolean
......@@ -238,10 +238,10 @@ Allows a process to obtain the standard input and output of its child processes,
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| pid | number | Yes| No| PID of the child process. This is a system API and cannot be called by third-party applications.|
| ppid | number | Yes| No| PPID of the child process. This is a system API and cannot be called by third-party applications.|
| exitCode | number | Yes| No| Exit code of the child process. This is a system API and cannot be called by third-party applications.|
| killed | boolean | Yes| No| Whether the parent process successfully sends a signal to the child process to terminate it. This is a system API and cannot be called by third-party applications.|
| pid | number | Yes| No| PID of the child process.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| ppid | number | Yes| No| PPID of the child process.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| exitCode | number | Yes| No| Exit code of the child process.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| killed | boolean | Yes| No| Whether the parent process successfully sends a signal to the child process to terminate it.<br>**System API**: This is a system API.<br>It is used only to test applications.|
### wait
......@@ -250,7 +250,9 @@ wait(): Promise&lt;number&gt;
Waits until the child process ends. This method uses a promise to return the exit code of the child process.
This is a system API and cannot be called by third-party applications.
**System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang
......@@ -277,7 +279,9 @@ getOutput(): Promise&lt;Uint8Array&gt;
Obtains the standard output of the child process.
This is a system API and cannot be called by third-party applications.
**System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang
......@@ -304,7 +308,9 @@ getErrorOutput(): Promise&lt;Uint8Array&gt;
Obtains the standard error output of the child process.
This is a system API and cannot be called by third-party applications.
**System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang
......@@ -331,7 +337,9 @@ close(): void
Closes the child process in running.
This is a system API and cannot be called by third-party applications.
**System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang
......@@ -349,7 +357,9 @@ kill(signal: number | string): void
Sends a signal to the specified child process to terminate it.
This is a system API and cannot be called by third-party applications.
**System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang
......@@ -593,7 +603,9 @@ runCmd(command: string, options?: { timeout?: number, killSignal?: number | stri
Forks a new process to run a shell command and returns the **ChildProcess** object.
This is a system API and cannot be called by third-party applications.
**System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang
......@@ -609,7 +621,7 @@ This is a system API and cannot be called by third-party applications.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| timeout | number | No| Maximum running time (in ms) of the child process. When the running time of the child process exceeds the value of this parameter, the parent process sends a **killSignal** to the child process to terminate it. The default value is **0**.|
| killSignal | number \| string | No| Signal sent to the child process when the running time of a child process exceeds the timeout period. The default value is **SIGTERM**.|
| killSignal | number&nbsp;\|&nbsp;string | No| Signal sent to the child process when the running time of a child process exceeds the timeout period. The default value is **SIGTERM**.|
| maxBuffer | number | No| Maximum buffer size for the standard input and output of the child process. When the size is exceeded, the child process will be terminated. The default value is **1024 \* 1024**.|
**Return value**
......@@ -650,7 +662,9 @@ on(type: string, listener: EventListener): void
Stores the events triggered by the user.
This is a system API and cannot be called by third-party applications.
**System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang
......@@ -682,7 +696,9 @@ off(type: string): boolean
Deletes the event stored by the user.
This is a system API and cannot be called by third-party applications.
**System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang
......@@ -737,7 +753,9 @@ cwd(): string
Obtains the working directory of this process.
This is a system API and cannot be called by third-party applications.
**System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang
......@@ -754,7 +772,9 @@ chdir(dir: string): void
Changes the working directory of this process.
This is a system API and cannot be called by third-party applications.
**System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang
......
# Device Usage Statistics
# @ohos.resourceschedule.usageStatistics (Device Usage Statistics)
This module provides APIs for collecting statistics on device usage.
......@@ -703,7 +703,7 @@ Queries FA usage records. This API uses an asynchronous callback to return a max
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ----------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[HapModuleInfo](#hapmoduleinfo)&gt;&gt; | Yes | Callback used to return a maximum of 1000 FA usage records.|
| callback | AsyncCallback&lt;Array&lt;[HapModuleInfo](#hapmoduleinfo)&gt;&gt; | Yes | Callback used to return a maximum of **maxNum** FA usage records.|
**Error codes**
......
# URL String Parsing
# @ohos.url (URL String Parsing)
> **NOTE**
>
......@@ -14,7 +14,7 @@ import Url from '@ohos.url'
### constructor<sup>9+</sup>
constructor(init?: string[][] | Record&lt;string, string&gt; | string | URLParams)
constructor(init?: string[][] | Record&lt;string, string&gt; | string | URLSearchParams)
A constructor used to create a **URLParams** instance.
......@@ -24,7 +24,7 @@ A constructor used to create a **URLParams** instance.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| init | string[][] \| Record&lt;string, string&gt; \| string \| URLParams | No| Input parameter objects, which include the following:<br>- **string[][]**: two-dimensional string array<br>- **Record&lt;string, string&gt;**: list of objects<br>- **string**: string<br>- **URLParams**: object|
| init | string[][] \| Record&lt;string, string&gt; \| string \| URLSearchParams | No| Input parameter objects, which include the following:<br>- **string[][]**: two-dimensional string array<br>- **Record&lt;string, string&gt;**: list of objects<br>- **string**: string<br>- **URLSearchParams**: object|
**Example**
......@@ -140,7 +140,7 @@ for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pair
### forEach<sup>9+</sup>
forEach(callbackfn: (value: string, key: string, searchParams: this) => void, thisArg?: Object): void
forEach(callbackFn: (value: string, key: string, searchParams: this) => void, thisArg?: Object): void
Traverses the key-value pairs in the **URLSearchParams** instance by using a callback.
......@@ -150,10 +150,10 @@ Traverses the key-value pairs in the **URLSearchParams** instance by using a cal
| 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.|
| callbackFn | function | Yes| Callback invoked to traverse the key-value pairs in the **URLSearchParams** instance.|
| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked.|
**Table 1** callbackfn parameter description
**Table 1** callbackFn parameter description
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
......@@ -165,7 +165,7 @@ Traverses the key-value pairs in the **URLSearchParams** instance by using a cal
```js
const myURLObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
myURLObject.URLParams.forEach((value, name, searchParams) => {
myURLObject.searchParams.forEach((value, name, searchParams) => {
console.log(name, value, myURLObject.searchParams === searchParams);
});
```
......@@ -366,18 +366,148 @@ params.append('fod', '3');
console.log(params.toString());
```
## URLSearchParams<sup>(deprecated)</sup>
## URL
### Attributes
**System capability**: SystemCapability.Utils.Lang
| 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.|
| URLParams | URLParams | Yes| No| **URLParams** object allowing access to the query parameters in a URL.|
| username | string | Yes| Yes| Username in a URL.|
### constructor<sup>(deprecated)</sup>
constructor(url: string, base?: string | URL)
Creates a URL.
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>](#constructor9+) instead.
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [parseURL<sup>9+</sup>](#parseurl9) instead.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| url | string | Yes| Input object.|
| base | string \| URL | No| Input parameter, which can be any of the following:<br>- **string**: string<br>- **URL**: string or object|
**Example**
```js
let mm = 'http://username:password@host:8080';
let a = new Url.URL("/", mm); // Output 'http://username:password@host:8080/';
let b = new Url.URL(mm); // Output 'http://username:password@host:8080/';
new Url.URL('path/path1', b); // Output 'http://username:password@host:8080/path/path1';
let c = new Url.URL('/path/path1', b); // Output 'http://username:password@host:8080/path/path1';
new Url.URL('/path/path1', c); // Output 'http://username:password@host:8080/path/path1';
new Url.URL('/path/path1', a); // Output 'http://username:password@host:8080/path/path1';
new Url.URL('/path/path1', "https://www.exampleUrl/fr-FR/toto"); // Output https://www.exampleUrl/path/path1
new Url.URL('/path/path1', ''); // Raises a TypeError exception as '' is not a valid URL
new Url.URL('/path/path1'); // Raises a TypeError exception as '/path/path1' is not a valid URL
new Url.URL('https://www.example.com', ); // Output https://www.example.com/
new Url.URL('https://www.example.com', b); // Output https://www.example.com/
```
### parseURL<sup>9+</sup>
static parseURL(url : string, base?: string | URL): URL
Parses a URL.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| url | string | Yes| Input object.|
| base | string \| URL | No| Input parameter, which can be any of the following:<br>- **string**: string<br>- **URL**: string or object|
**Error codes**
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
| 10200002 | Invalid url string. |
**Example**
```js
let mm = 'http://username:password@host:8080';
Url.URL.parseURL(mm); // Output 'http://username:password@host:8080/';
```
### tostring
toString(): string
Converts the parsed URL into a string.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
| string | Website address in a serialized string.|
**Example**
```js
const url = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toString();
```
### toJSON
toJSON(): string
Converts the parsed URL into a JSON string.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
| string | Website address in a serialized string.|
**Example**
```js
const url = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toJSON();
```
## URLSearchParams<sup>(deprecated)</sup>
### constructor<sup>(deprecated)</sup>
constructor(init?: string[][] | Record&lt;string, string&gt; | string | URLSearchParams)
A constructor used to create a **URLSearchParams** instance.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>](#constructor9) instead.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
......@@ -398,14 +528,14 @@ let params = new Url.URLSearchParams(urlObject.search);
### append<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.append<sup>9+</sup>](#append9) instead.
append(name: string, value: string): void
Appends a key-value pair into the query string.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.append<sup>9+</sup>](#append9) instead.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
......@@ -425,14 +555,14 @@ paramsObject.append('fod', '3');
### delete<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.delete<sup>9+</sup>](#delete9) instead.
delete(name: string): void
Deletes key-value pairs of the specified key.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.delete<sup>9+</sup>](#delete9) instead.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
......@@ -451,14 +581,14 @@ paramsobject.delete('fod');
### getAll<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.getAll<sup>9+</sup>](#getall9) instead.
getAll(name: string): string[]
Obtains all the key-value pairs based on the specified key.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.getAll<sup>9+</sup>](#getall9) instead.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
......@@ -484,14 +614,14 @@ console.log(params.getAll('fod').toString()) // Output ["1","3"].
### entries<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.entries<sup>9+</sup>](#entries9) instead.
entries(): IterableIterator<[string, string]>
Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and the first and second fields of each array are the key and value respectively.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.entries<sup>9+</sup>](#entries9) instead.
**System capability**: SystemCapability.Utils.Lang
**Return value**
......@@ -511,24 +641,25 @@ for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pair
### forEach<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.forEach<sup>9+</sup>](#foreach9) instead.
forEach(callbackfn: (value: string, key: string, searchParams: this) => void, thisArg?: Object): void
forEach(callbackFn: (value: string, key: string, searchParams: this) => void, thisArg?: Object): void
Traverses the key-value pairs in the **URLSearchParams** instance by using a callback.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.forEach<sup>9+</sup>](#foreach9) instead.
**System capability**: SystemCapability.Utils.Lang
**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.|
| callbackFn | function | Yes| Callback invoked to traverse the key-value pairs in the **URLSearchParams** instance.|
| thisArg | Object | No| Value to use when **callbackFn** is invoked.|
**Table 1** callbackfn parameter description
**Table 1** callbackFn parameter description
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
......@@ -547,14 +678,15 @@ myURLObject.searchParams.forEach((value, name, searchParams) => {
### get<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.get<sup>9+</sup>](#get9) instead.
get(name: string): string | null
Obtains the value of the first key-value pair based on the specified key.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.get<sup>9+</sup>](#get9) instead.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
......@@ -580,14 +712,15 @@ let age = parseInt(paramsObject.get("age"), 10); // is the number 18
### has<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.has<sup>9+</sup>](#has9) instead.
has(name: string): boolean
Checks whether a key has a value.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.has<sup>9+</sup>](#has9) instead.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
......@@ -612,14 +745,15 @@ paramsObject.has('bard') === true;
### set<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.set<sup>9+</sup>](#set9) instead.
set(name: string, value: string): void
Sets the value for a key. If key-value pairs matching the specified key exist, the value of the first key-value pair will be set to the specified value and other key-value pairs will be deleted. Otherwise, the key-value pair will be appended to the query string.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.set<sup>9+</sup>](#set9) instead.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
......@@ -639,14 +773,15 @@ paramsObject.set('baz', '3'); // Add a third parameter.
### sort<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.sort<sup>9+</sup>](#sort9) instead.
sort(): void
Sorts all key-value pairs contained in this object based on the Unicode code points of the keys and returns undefined. This method uses a stable sorting algorithm, that is, the relative order between key-value pairs with equal keys is retained.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.sort<sup>9+</sup>](#sort9) instead.
**System capability**: SystemCapability.Utils.Lang
**Example**
......@@ -659,14 +794,15 @@ console.log(searchParamsObject.toString()); // Display the sorted query string /
### keys<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.keys<sup>9+</sup>](#keys9) instead.
keys(): IterableIterator&lt;string&gt;
Obtains an ES6 iterator that contains the keys of all the key-value pairs.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.keys<sup>9+</sup>](#keys9) instead.
**System capability**: SystemCapability.Utils.Lang
**Return value**
......@@ -686,14 +822,15 @@ for (var key of searchParamsObject .keys()) { // Output key-value pairs
### values<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.values<sup>9+</sup>](#values9) instead.
values(): IterableIterator&lt;string&gt;
Obtains an ES6 iterator that contains the values of all the key-value pairs.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.values<sup>9+</sup>](#values9) instead.
**System capability**: SystemCapability.Utils.Lang
**Return value**
......@@ -714,15 +851,14 @@ for (var value of searchParams.values()) {
### [Symbol.iterator]<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [[Symbol.iterator]<sup>9+</sup>](#symboliterator9) instead.
[Symbol.iterator]\(): IterableIterator&lt;[string, string]&gt;
Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and the first and second fields of each array are the key and value respectively.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [Symbol.iterator]<sup>9+</sup>](#symboliterator9) instead.
**System capability**: SystemCapability.Utils.Lang
**Return value**
......@@ -741,14 +877,15 @@ for (const [name, value] of paramsObject) {
```
### tostring<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.tostring<sup>9+</sup>](#tostring9) instead.
toString(): string
Obtains search parameters that are serialized as a string and, if necessary, percent-encodes the characters in the string.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tostring<sup>9+</sup>](#tostring9) instead.
**System capability**: SystemCapability.Utils.Lang
**Return value**
......@@ -784,14 +921,17 @@ console.log(params.toString());
| 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.|
| searchParams | URLSearchParams | Yes| No| **URLSearchParams** object allowing access to the query parameters in a URL.|
| URLParams | URLParams | Yes| No| **URLParams** object allowing access to the query parameters in a URL.|
| username | string | Yes| Yes| Username in a URL.|
### constructor<sup>(deprecated)</sup>
### constructor
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [parseURL<sup>9+</sup>](#parseurl9) instead.
constructor(url?: string, base?: string | URL)
constructor(url: string, base?: string | URL)
Creates a URL.
......@@ -807,23 +947,23 @@ Creates a URL.
**Example**
```js
let mm = 'http://username:password@host:8080';
let a = new Url.URL("/", mm); // Output 'http://username:password@host:8080/';
let b = new Url.URL(mm); // Output 'http://username:password@host:8080/';
new Url.URL('path/path1', b); // Output 'http://username:password@host:8080/path/path1';
let c = new Url.URL('/path/path1', b); // Output 'http://username:password@host:8080/path/path1';
new Url.URL('/path/path1', c); // Output 'http://username:password@host:8080/path/path1';
new Url.URL('/path/path1', a); // Output 'http://username:password@host:8080/path/path1';
let mm = 'https://username:password@host:8080';
let a = new Url.URL("/", mm); // Output 'https://username:password@host:8080/';
let b = new Url.URL(mm); // Output 'https://username:password@host:8080/';
new Url.URL('path/path1', b); // Output 'https://username:password@host:8080/path/path1';
let c = new Url.URL('/path/path1', b); // Output 'https://username:password@host:8080/path/path1';
new Url.URL('/path/path1', c); // Output 'https://username:password@host:8080/path/path1';
new Url.URL('/path/path1', a); // Output 'https://username:password@host:8080/path/path1';
new Url.URL('/path/path1', "https://www.exampleUrl/fr-FR/toto"); // Output https://www.exampleUrl/path/path1
new Url.URL('/path/path1', ''); // Raises a TypeError exception as '' is not a valid URL
new Url.URL('/path/path1'); // Raises a TypeError exception as '/path/path1' is not a valid URL
new Url.URL('http://www.shanxi.com', ); // Output http://www.shanxi.com/
new Url.URL('http://www.shanxi.com', b); // Output http://www.shanxi.com/
new Url.URL('https://www.example.com', ); // Output https://www.example.com/
new Url.URL('https://www.example.com', b); // Output https://www.example.com/
```
### parseURL<sup>9+</sup>
static parseURL(inputUrl : string, inputBase ?: string | URL)
static parseURL(url : string, base?: string | URL): URL
Parses a URL.
......@@ -833,14 +973,14 @@ Parses a URL.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| inputUrl | string | Yes| Input object.|
| inputBase | string \| URL | No| Input parameter, which can be any of the following:<br>- **string**: string<br>- **URL**: string or object|
| url | string | Yes| Input object.|
| base | string \| URL | No| Input parameter, which can be any of the following:<br>- **string**: string<br>- **URL**: string or object|
**Example**
```js
let mm = 'http://username:password@host:8080';
Url.URL.parseURL(mm); // Output 'http://username:password@host:8080/';
let mm = 'https://username:password@host:8080';
Url.URL.parseURL(mm); // Output 'https://username:password@host:8080/';
```
### tostring
......@@ -860,7 +1000,7 @@ Converts the parsed URL into a string.
**Example**
```js
const url = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
const url = new Url.URL('https://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toString();
```
......@@ -881,7 +1021,7 @@ Converts the parsed URL into a JSON string.
**Example**
```js
const url = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
const url = new Url.URL('https://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toJSON();
```
<!--no_check-->
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册