mirror of
https://github.com/openharmony/js_api_module.git
synced 2026-08-24 22:21:26 -04:00
Signed-off-by: lifansheng <lifansheng1@huawei.com>
On branch OpenHarmony-3.0-LTS Your branch is up to date with 'origin/OpenHarmony-3.0-LTS'.
This commit is contained in:
@@ -1,244 +1,3 @@
|
||||
In the jsapi / api directory, the definitions of some interfaces refer to their definitions in the webapi.
|
||||
The following is a reference to the defined interface:
|
||||
|
||||
declare namespace url {
|
||||
class URLSearchParams {
|
||||
/**
|
||||
* A parameterized constructor used to create an URLSearchParams instance.
|
||||
* As the input parameter of the constructor function, init supports four types.
|
||||
* The input parameter is a character string two-dimensional array.
|
||||
* The input parameter is the object list.
|
||||
* The input parameter is a character string.
|
||||
* The input parameter is the URLSearchParams object.
|
||||
*/
|
||||
constructor(init?: string[][] | Record<string, string> | string | URLSearchParams);
|
||||
|
||||
/**
|
||||
* Appends a specified key/value pair as a new search parameter.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
* @param name Key name of the search parameter to be inserted.
|
||||
* @param value Values of search parameters to be inserted.
|
||||
*/
|
||||
append(name: string, value: string): void;
|
||||
|
||||
/**
|
||||
* Deletes the given search parameter and its associated value,from the list of all search parameters.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
* @param Name of the key-value pair to be deleted.
|
||||
*/
|
||||
delete(name: string): void;
|
||||
|
||||
/**
|
||||
* Returns all key-value pairs associated with a given search parameter as an array.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
* @param Name Specifies the name of a key value.
|
||||
* @return string[] Returns all key-value pairs with the specified name.
|
||||
*/
|
||||
getAll(name: string): string[];
|
||||
|
||||
/**
|
||||
* Returns an ES6 iterator. Each item of the iterator is a JavaScript Array.
|
||||
* The first item of Array is name, and the second item of Array is value.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
* @return Returns an iterator for ES6.
|
||||
*/
|
||||
entries(): IterableIterator<[string, string]>;
|
||||
|
||||
/**
|
||||
* Callback functions are used to traverse key-value pairs on the URLSearchParams instance object.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
* @param value Current traversal key value.
|
||||
* @param key Indicates the name of the key that is traversed.
|
||||
* @param searchParams The instance object that is currently calling the forEach method.
|
||||
*/
|
||||
forEach(callbackfn: (value: string, key: string, searchParams: this) => void): void;
|
||||
|
||||
/**
|
||||
* Returns the first value associated to the given search parameter.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
* @param name Specifies the name of a key-value pair.
|
||||
* @return Returns the first value found by name. If no value is found, null is returned.
|
||||
*/
|
||||
get(name: string): string | null;
|
||||
|
||||
/**
|
||||
* Returns a Boolean that indicates whether a parameter with the specified name exists.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
* @param name Specifies the name of a key-value pair.
|
||||
* @return Returns a Boolean value that indicates whether a found
|
||||
*/
|
||||
has(name: string): boolean;
|
||||
|
||||
/**
|
||||
* Sets the value associated with a given search parameter to the
|
||||
* given value. If there were several matching values, this method
|
||||
* deletes the others. If the search parameter doesn't exist, this
|
||||
* method creates it.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
* @param name Key name of the parameter to be set.
|
||||
* @param value Indicates the parameter value to be set.
|
||||
*/
|
||||
set(name: string, value: string): void;
|
||||
|
||||
/**
|
||||
* Sort all key/value pairs contained in this object in place and return undefined.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
*/
|
||||
sort(): void;
|
||||
|
||||
/**
|
||||
* Returns an iterator allowing to go through all keys contained in this object.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
* @return Returns an ES6 Iterator over the names of each name-value pair.
|
||||
*/
|
||||
keys(): IterableIterator<string>;
|
||||
|
||||
/**
|
||||
* Returns an iterator allowing to go through all values contained in this object.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
* @return Returns an ES6 Iterator over the values of each name-value pair.
|
||||
*/
|
||||
values(): IterableIterator<string>;
|
||||
|
||||
/**
|
||||
* Returns an iterator allowing to go through all key/value
|
||||
* pairs contained in this object.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
* @return Returns an ES6 iterator. Each item of the iterator is a JavaScript Array.
|
||||
* The first item of Array is name, and the second item of Array is value.
|
||||
*/
|
||||
[Symbol.iterator](): IterableIterator<[string, string]>;
|
||||
|
||||
/**
|
||||
* Returns a query string suitable for use in a URL.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
* @return Returns a search parameter serialized as a string, percent-encoded if necessary.
|
||||
*/
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
class URL {
|
||||
/**
|
||||
* URL constructor, which is used to instantiate a URL object.
|
||||
* url: Absolute or relative input URL to resolve. Base is required if input is relative.
|
||||
* If input is an absolute value, base ignores the value.
|
||||
* base: Base URL to parse if input is not absolute.
|
||||
*/
|
||||
constructor(url: string, base?: string | URL);
|
||||
|
||||
/**
|
||||
* Returns the serialized URL as a string.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
* @return Returns the serialized URL as a string.
|
||||
*/
|
||||
toString(): string;
|
||||
|
||||
/**
|
||||
* Returns the serialized URL as a string.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
* @return Returns the serialized URL as a string.
|
||||
*/
|
||||
toJSON(): string;
|
||||
|
||||
/**
|
||||
* Gets and sets the fragment portion of the URL.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
*/
|
||||
hash: string;
|
||||
|
||||
/**
|
||||
* Gets and sets the host portion of the URL.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
*/
|
||||
host: string;
|
||||
|
||||
/**
|
||||
* Gets and sets the host name portion of the URL,not include the port.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
*/
|
||||
hostname: string;
|
||||
|
||||
/**
|
||||
* Gets and sets the serialized URL.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
*/
|
||||
href: string;
|
||||
|
||||
/**
|
||||
* Gets the read-only serialization of the URL's origin.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
*/
|
||||
readonly origin: string;
|
||||
|
||||
/**
|
||||
* Gets and sets the password portion of the URL.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
*/
|
||||
password: string;
|
||||
|
||||
/**
|
||||
* Gets and sets the path portion of the URL.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
*/
|
||||
pathname: string;
|
||||
|
||||
/**
|
||||
* Gets and sets the port portion of the URL.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
*/
|
||||
port: string;
|
||||
|
||||
/**
|
||||
* Gets and sets the protocol portion of the URL.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
*/
|
||||
protocol: string;
|
||||
|
||||
/**
|
||||
* Gets and sets the serialized query portion of the URL.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
*/
|
||||
search: string;
|
||||
|
||||
/**
|
||||
* Gets the URLSearchParams object that represents the URL query parameter.
|
||||
* This property is read-only, but URLSearchParams provides an object that can be used to change
|
||||
* the URL instance. To replace the entire query parameter for a URL, use url.searchsetter.
|
||||
* @since 7
|
||||
* @sysCap SystemCapability.CCRuntime
|
||||
* @note Be careful when modifying with .searchParams, because the URLSearchParams
|
||||
* object uses different rules to determine which characters to
|
||||
* percent-encode according to the WHATWG specification.
|
||||
*/
|
||||
readonly searchParams: URLSearchParams;
|
||||
username: string;
|
||||
}
|
||||
}
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
|
||||
@@ -14,7 +14,7 @@ The interface of URL is used to parse, construct, normalize, and encode URLs. Th
|
||||
|
||||
URI Represents a Uniform Resource Identifier (URI) reference.
|
||||
|
||||
XML representation refers to extensible markup language。
|
||||
XML representation refers to extensible markup language.
|
||||
|
||||
## Contents
|
||||
|
||||
@@ -36,7 +36,7 @@ base/compileruntime/js_api_module/
|
||||
│ ├── username # username attribute
|
||||
│ ├── toString() # toString method
|
||||
│ └── toJSON() # toJSON method
|
||||
├── Class: URLSearchParams # URLSearchParams class
|
||||
├── Class: URLSearchParams # URLSearchParams class
|
||||
│ ├── new URLSearchParams() # Create URLSearchParams object
|
||||
│ ├── new URLSearchParams(string) # Create URLSearchParams object
|
||||
│ ├── new URLSearchParams(obj) # Create URLSearchParams object
|
||||
@@ -54,9 +54,9 @@ base/compileruntime/js_api_module/
|
||||
│ ├── toString() # toString method
|
||||
│ ├── values() # values method
|
||||
│ └── urlSearchParams[Symbol.iterator]() # Create URLSearchParams object
|
||||
├── Class:URI # URI class
|
||||
│ ├── URI(String str) # URI class
|
||||
│ ├── scheme # Create URI object
|
||||
├── Class:URI # URI class
|
||||
│ ├── URI(String str) # URI class
|
||||
│ ├── scheme # Create URI object
|
||||
│ ├── authority # scheme attribute
|
||||
│ ├── ssp # authority attribute
|
||||
│ ├── userinfo # ssp attribute
|
||||
@@ -66,13 +66,13 @@ base/compileruntime/js_api_module/
|
||||
│ ├── fragment # query attribute
|
||||
│ ├── path # fragment attribute
|
||||
│ ├── equals(Object ob) # path method
|
||||
│ ├── normalize() # equals method
|
||||
│ ├── isAbsolute() # normalize method
|
||||
│ ├── normalize() # isAbsolute method
|
||||
│ ├── normalize() # equals method
|
||||
│ ├── isAbsolute() # normalize method
|
||||
│ ├── normalize() # isAbsolute method
|
||||
│ └── toString() # normalize method
|
||||
└── Class:ConvertXml # ConvertXml class
|
||||
├── ConvertXml() # Create convertxml class object
|
||||
└── convert(String xml, Object options) # Convert method
|
||||
└── Class:ConvertXml # ConvertXml class
|
||||
├── ConvertXml() # Create convertxml class object
|
||||
└── convert(String xml, Object options) # Convert method
|
||||
```
|
||||
|
||||
## Illustrate
|
||||
@@ -80,10 +80,9 @@ base/compileruntime/js_api_module/
|
||||
### Interface Description
|
||||
|
||||
|
||||
| Interface name | Illustrate |
|
||||
| Interface name | Illustrate |
|
||||
| -------- | -------- |
|
||||
//URL
|
||||
| new URL(url: string,base?:string I URL) | Create and return a URL object that references the URL specified by the absolute URL string, the relative URL string, and the basic URL string. |
|
||||
| new URL(url: string,base?:string \| URL) | Create and return a URL object that references the URL specified by the absolute URL string, the relative URL string, and the basic URL string. |
|
||||
| tostring():string | The stringification method returns a USVString containing the complete URL. It is equivalent to the read-only URL.href. |
|
||||
| toJSON():string | This method returns a USVString, which contains a serialized URL version. |
|
||||
| new URLSearchParams() | The URLSearchParams() constructor has no parameters. This method creates and returns a new URLSearchParams object. The beginning'?' character will be ignored. |
|
||||
@@ -94,18 +93,17 @@ base/compileruntime/js_api_module/
|
||||
| set(name: string, value string): void | Retrieve whether the searchParams object contains a key-value pair whose key is name. If not, add the key-value pair, if any, modify the value corresponding to the first key in the object, and delete the remaining key-value pairs whose key is name. |
|
||||
| sort(): void | According to the Unicode code point of the key, sort all key/value pairs contained in this object and return undefined. |
|
||||
| toString(): string | According to the searchParams object, the query string applicable in the URL is returned. |
|
||||
| keys(): iterableIterator<string> | Return an iterator, which allows iterating through all the key values contained in the object. |
|
||||
| values(): iterableIterator<string> | Returns an iterator, which allows iterating over all the value values contained in the object. |
|
||||
| keys(): iterableIterator\<string> | Return an iterator, which allows iterating through all the key values contained in the object. |
|
||||
| values(): iterableIterator\<string> | Returns an iterator, which allows iterating over all the value values contained in the object. |
|
||||
| append(name: string, value: string): void | Insert the name, value key-value pair in the searchParams object. |
|
||||
| delete(name: string): void | Traverse the searchParams object, find all the names, and delete the corresponding key-value pairs. |
|
||||
| get(name: string): string | Retrieve the first name in the searchParams object and return the value corresponding to the name key. |
|
||||
| getAll(name: string): string[] | Retrieve all names in the searchParams object and return all the values corresponding to the name key. |
|
||||
| entries(): iterableIterator<[string, string]> | Returns an iterator that allows iterating through all key/value pairs contained in the searchParams object. |
|
||||
| forEach(): void | Through the callback function to traverse the key-value pairs on the URLSearchParams instance object. |
|
||||
| urlSearchParams[Symbol.iterator] () | Returns an ES6 iterator for each name-value pair in the query string. Each item of the iterator is a JavaScript array. |
|
||||
//URI
|
||||
| urlSearchParams\[Symbol.iterator]() | Returns an ES6 iterator for each name-value pair in the query string. Each item of the iterator is a JavaScript array. |
|
||||
| URI(String str) | Construct the URI by parsing the given input parameter (String str). This constructor parses the given string strictly in accordance with the grammatical provisions in RFC 2396 Appendix A. |
|
||||
| getScheme() | Return the scheme component of this URI, or null if the scheme is not defined |
|
||||
| getScheme() | Return the scheme component of this URI, or null if the scheme is not defined. |
|
||||
| getAuthority() | Returns the decoded authority component of this URI, or null if authority is not defined. The string returned by this method is the same as the string returned by the getRawAuthority method, except that all escaped octet sequences are decoded. |
|
||||
| getSchemeSpecificPart() | Returns the decoding scheme-specific part of this URI. The string returned by this method is the same as the string returned by the getRawSchemeSpecificPart method, except that all escaped octet sequences are decoded. |
|
||||
| getUserInfo() | Returns the decoded userinfo component of this URI. The userinfo component of the URI (if defined) only contains characters in unreserved, punctuation, escape, and other categories. |
|
||||
@@ -118,7 +116,6 @@ base/compileruntime/js_api_module/
|
||||
| normalize() | Normalize the path of this URI. If this URI is opaque, or its path is already in normal form, then this URI is returned. Otherwise, a new URI identical to this URI will be constructed. |
|
||||
| isAbsolute() | Determine whether this URI is absolute. If and only if it has a scheme component, the URI is absolute and the return value is true, otherwise the return value is false. |
|
||||
| toString() | Return the content of this URI as a string. |
|
||||
//ConvertXml
|
||||
| ConvertXml() | The constructor used to construct the convertxml class object. This constructor does not need to pass in parameters. |
|
||||
| convert(String xml, Object options) | Returns a JavaScript object that converts an XML string as required by the option. |
|
||||
|
||||
@@ -126,8 +123,6 @@ base/compileruntime/js_api_module/
|
||||
|
||||
The usage of each interface is as follows:
|
||||
|
||||
1.URL
|
||||
|
||||
1、new URL(url: string,base?:string|URL)
|
||||
```
|
||||
let b = new URL('https://developer.mozilla.org'); // => 'https://developer.mozilla.org/'
|
||||
@@ -173,7 +168,6 @@ console.log(params.getAll('query'));
|
||||
7、new URLSearchParams(iterable)
|
||||
```
|
||||
let params;
|
||||
|
||||
// Using an array
|
||||
params = new URLSearchParams([
|
||||
['user', 'abc'],
|
||||
@@ -199,13 +193,13 @@ params .sort();
|
||||
```
|
||||
console.log(params .toString()); // =>bar=2&baz=3&foo=1'
|
||||
```
|
||||
12、keys(): iterableIterator<string>
|
||||
12、keys(): iterableIterator\<string>
|
||||
```
|
||||
for(var key of params.keys()) {
|
||||
console.log(key);
|
||||
} // =>bar baz foo
|
||||
```
|
||||
13、values(): iterableIterator<string>
|
||||
13、values(): iterableIterator\<string>
|
||||
```
|
||||
for(var value of params.values()) {
|
||||
console.log(value);
|
||||
@@ -252,93 +246,89 @@ for (const [name, value] of params) {
|
||||
// xyz ba
|
||||
```
|
||||
|
||||
2.URI
|
||||
|
||||
1、URI(String str)
|
||||
21、URI(String str)
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
|
||||
```
|
||||
2、scheme
|
||||
22、scheme
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
|
||||
gaogao.scheme // => "http";
|
||||
```
|
||||
3、authority
|
||||
23、authority
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
|
||||
gaogao.authority // => "gg:gaogao@www.baidu.com:99";
|
||||
```
|
||||
4、ssp
|
||||
24、ssp
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
|
||||
gaogao.ssp " // => gg:gaogao@www.baidu.com:99/path/path?query";
|
||||
```
|
||||
5、userinfo
|
||||
25、userinfo
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
|
||||
gaogao.userinfo // => "gg:gaogao";
|
||||
```
|
||||
6、host
|
||||
26、host
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
|
||||
gaogao.host // => "www.baidu.com";
|
||||
```
|
||||
7、port
|
||||
27、port
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
|
||||
gaogao.port // => "99";
|
||||
```
|
||||
8、query
|
||||
28、query
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
|
||||
gaogao.query // => "query";
|
||||
```
|
||||
9、fragment
|
||||
29、fragment
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
|
||||
gaogao.fragment // => "fagment";
|
||||
```
|
||||
10、path
|
||||
30、path
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
|
||||
gaogao.path // => "/path/path";
|
||||
```
|
||||
11、equals(Object ob)
|
||||
31、equals(Object ob)
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment');
|
||||
let gaogao1 = gaogao;
|
||||
let res = gaogao.equals(gaogao1);
|
||||
console.log(res); // => true;
|
||||
```
|
||||
12、normalize()
|
||||
32、normalize()
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/66./../././mm/.././path1?query#fagment');
|
||||
let res = gaogao.normalize();
|
||||
console.log(res.path); // => "/path/path1"
|
||||
console.log(res.toString()); // => "http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/path1?query#fagment"
|
||||
```
|
||||
13、isAbsolute()
|
||||
33、isAbsolute()
|
||||
```
|
||||
let gaogao = new Uri.URI('f/tp://username:password@www.baidu.com:88/path?query#fagment');
|
||||
let res = gaogao.isAbsolute();
|
||||
console.log(res); //=> false;
|
||||
```
|
||||
14、toString()
|
||||
34、toString()
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment');
|
||||
let res = gaogao.toString();
|
||||
console.log(res.toString()); // => 'http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment';
|
||||
```
|
||||
|
||||
3.ConvertXml
|
||||
|
||||
1、ConvertXml()
|
||||
35、ConvertXml()
|
||||
```
|
||||
var convertml = new convertXml.ConvertXml();
|
||||
```
|
||||
2、convert(String xml, Object options)
|
||||
36、convert(String xml, Object options)
|
||||
```
|
||||
var result = convertml.convert(xml, {compact: false, spaces: 4});
|
||||
```
|
||||
## Related warehouse
|
||||
[js_api_module Subsystem](https://gitee.com/OHOS_STD/js_api_module)
|
||||
|
||||
@@ -346,4 +336,4 @@ var result = convertml.convert(xml, {compact: false, spaces: 4});
|
||||
|
||||
## License
|
||||
|
||||
URL is available under [Mozilla license](https://www.mozilla.org/en-US/MPL/), and the documentation is detailed in [documentation](https://gitee.com/openharmony/js_api_module/blob/master/LICENSE_docs). See [LICENSE](https://gitee.com/openharmony/js_api_module/blob/master/LICENSE) for the full license text.
|
||||
URL is available under [Mozilla license](https://www.mozilla.org/en-US/MPL/), and the documentation is detailed in [documentation](https://gitee.com/openharmony/js_api_module/blob/master/mozilla_docs.txt). See [LICENSE](https://gitee.com/openharmony/js_api_module/blob/master/LICENSE) for the full license text.
|
||||
+35
-46
@@ -36,7 +36,7 @@ base/compileruntime/js_api_module/
|
||||
│ ├── username # username属性
|
||||
│ ├── toString() # toString方法
|
||||
│ └── toJSON() # toJSON方法
|
||||
├── Class: URLSearchParams # URLSearchParams类
|
||||
├── Class: URLSearchParams # URLSearchParams类
|
||||
│ ├── new URLSearchParams() # 创建URLSearchParams对象
|
||||
│ ├── new URLSearchParams(string) # 创建URLSearchParams对象
|
||||
│ ├── new URLSearchParams(obj) # 创建URLSearchParams对象
|
||||
@@ -54,8 +54,8 @@ base/compileruntime/js_api_module/
|
||||
│ ├── toString() # toString方法
|
||||
│ ├── values() # values方法
|
||||
│ └── urlSearchParams[Symbol.iterator]() # 创建URLSearchParams对象
|
||||
├── Class:URI # URI类
|
||||
│ ├── URI(String str) # 创建URI对象
|
||||
├── Class:URI # URI类
|
||||
│ ├── URI(String str) # 创建URI对象
|
||||
│ ├── scheme # scheme属性
|
||||
│ ├── authority # authority属性
|
||||
│ ├── ssp # ssp属性
|
||||
@@ -66,13 +66,13 @@ base/compileruntime/js_api_module/
|
||||
│ ├── fragment # fragment属性
|
||||
│ ├── path # path属性
|
||||
│ ├── equals(Object ob) # equals方法
|
||||
│ ├── normalize() # normalize方法
|
||||
│ ├── isAbsolute() # isAbsolute方法
|
||||
│ ├── normalize() # normalize方法
|
||||
│ ├── normalize() # normalize方法
|
||||
│ ├── isAbsolute() # isAbsolute方法
|
||||
│ ├── normalize() # normalize方法
|
||||
│ └── toString() # toString方法
|
||||
└── Class:ConvertXml # ConvertXml类
|
||||
├── ConvertXml() # 创建ConvertXml类对象
|
||||
└── convert(String xml, Object options) # convert方法
|
||||
└── Class:ConvertXml # ConvertXml类
|
||||
├── ConvertXml() # 创建ConvertXml类对象
|
||||
└── convert(String xml, Object options) # convert方法
|
||||
```
|
||||
|
||||
## 说明
|
||||
@@ -80,10 +80,9 @@ base/compileruntime/js_api_module/
|
||||
### 接口说明
|
||||
|
||||
|
||||
| 接口名 | 说明 |
|
||||
| 接口名 | 说明 |
|
||||
| -------- | -------- |
|
||||
//URL
|
||||
| URL(url: string,base?:string I URL) | 创建并返回一个URL对象,该URL对象引用使用绝对URL字符串,相对URL字符串和基本URL字符串指定的URL。 |
|
||||
| URL(url: string,base?:string \| URL) | 创建并返回一个URL对象,该URL对象引用使用绝对URL字符串,相对URL字符串和基本URL字符串指定的URL。 |
|
||||
| tostring():string | 该字符串化方法返回一个包含完整 URL 的 USVString。它的作用等同于只读的 URL.href。 |
|
||||
| toJSON():string | 该方法返回一个USVString,其中包含一个序列化的URL版本。 |
|
||||
| new URLSearchParams() | URLSearchParams() 构造器无入参,该方法创建并返回一个新的URLSearchParams 对象。 开头的'?' 字符会被忽略。 |
|
||||
@@ -94,17 +93,15 @@ base/compileruntime/js_api_module/
|
||||
| set(name: string, value string): void | 检索searchParams对象中是否含有key为name的键值对。没有的话则添加该键值对,有的话则修改对象中第一个key所对应的value,并删除键为name的其余键值对。 |
|
||||
| sort(): void | 根据键的Unicode代码点,对包含在此对象中的所有键/值对进行排序,并返回undefined。 |
|
||||
| toString(): string | 根据searchParams对象,返回适用在URL中的查询字符串。 |
|
||||
| keys(): iterableIterator<string> | 返回一个iterator,遍历器允许遍历对象中包含的所有key值。 |
|
||||
| values(): iterableIterator<string> | 返回一个iterator,遍历器允许遍历对象中包含的所有value值。 |
|
||||
| keys(): iterableIterator\<string> | 返回一个iterator,遍历器允许遍历对象中包含的所有key值。 |
|
||||
| values(): iterableIterator\<string> | 返回一个iterator,遍历器允许遍历对象中包含的所有value值。 |
|
||||
| append(name: string, value: string): void | 在searchParams对象中插入name, value键值对。 |
|
||||
| delete(name: string): void | 遍历searchParams对象,查找所有的name,删除对应的键值对。 |
|
||||
| get(name: string): string | 检索searchParams对象中第一个name,返回name键对应的值。 |
|
||||
| getAll(name: string): string[] | 检索searchParams对象中所有name,返回name键对应的所有值。 |
|
||||
| entries(): iterableIterator<[string, string]> | 返回一个iterator,允许遍历searchParams对象中包含的所有键/值对。 |
|
||||
| forEach(): void | 通过回调函数来遍历URLSearchParams实例对象上的键值对。 |
|
||||
| urlSearchParams[Symbol.iterator] () | 返回查询字符串中每个名称-值对的ES6迭代器。迭代器的每个项都是一个JavaScript数组。 |
|
||||
|
||||
//URI
|
||||
| urlSearchParams\[Symbol.iterator]() | 返回查询字符串中每个名称-值对的ES6迭代器。迭代器的每个项都是一个JavaScript数组。 |
|
||||
| URI(String str) | 通过解析给定入参(String str)来构造URI。此构造函数严格按照RFC 2396附录A中的语法规定解析给定字符串。 |
|
||||
| scheme | 返回此 URI 的scheme部分,如果scheme未定义,则返回 null |
|
||||
| authority | 返回此 URI 的解码authority部分,如果authority未定义,则返回 null。 |
|
||||
@@ -118,8 +115,6 @@ base/compileruntime/js_api_module/
|
||||
| equals(Object ob) | 测试此 URI 是否与另一个对象相等。如果给定的对象不是 URI,则此方法立即返回 false。 |
|
||||
| normalize() | 规范化这个 URI 的路径。如果这个 URI 的path不规范,将规范后构造一个新 URI对象返回。 |
|
||||
| isAbsolute() | 判断这个 URI 是否是绝对的。当且仅当它具有scheme部分时,URI 是绝对的,返回值为true,否则返回值为false。 |
|
||||
|
||||
//ConvertXml
|
||||
| ConvertXml() | 用于构造ConvertXml类对象的构造函数。此构造函数无需传入参数。 |
|
||||
| convert(String xml, Object options) | 返回按选项要求转化xml字符串的JavaScrip对象。 |
|
||||
|
||||
@@ -127,8 +122,6 @@ base/compileruntime/js_api_module/
|
||||
|
||||
各接口使用方法如下:
|
||||
|
||||
1.URL
|
||||
|
||||
1、new URL(url: string,base?:string|URL)
|
||||
```
|
||||
let b = new URL('https://developer.mozilla.org'); // => 'https://developer.mozilla.org/'
|
||||
@@ -140,7 +133,7 @@ let a = new URL( 'sca/./path/path/../scasa/text', 'http://www.example.com');
|
||||
```
|
||||
const url = new URL('http://10.0xFF.O400.235:8080/directory/file?query#fragment');
|
||||
url.toString() // => 'http://10.0xff.o400.235:8080/directory/file?query#fragment'
|
||||
|
||||
|
||||
const url = new URL("http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html");
|
||||
url.toString() // => 'http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/index.html'
|
||||
|
||||
@@ -200,13 +193,13 @@ params .sort();
|
||||
```
|
||||
console.log(params .toString()); // =>bar=2&baz=3&foo=1'
|
||||
```
|
||||
12、keys(): iterableIterator<string>
|
||||
12、keys(): iterableIterator\<string>
|
||||
```
|
||||
for(var key of params.keys()) {
|
||||
console.log(key);
|
||||
} // =>bar baz foo
|
||||
```
|
||||
13、values(): iterableIterator<string>
|
||||
13、values(): iterableIterator\<string>
|
||||
```
|
||||
for(var value of params.values()) {
|
||||
console.log(value);
|
||||
@@ -253,91 +246,87 @@ for (const [name, value] of params) {
|
||||
// xyz ba
|
||||
```
|
||||
|
||||
2.URI
|
||||
|
||||
1、URI(String str)
|
||||
21、URI(String str)
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
|
||||
```
|
||||
2、scheme
|
||||
22、scheme
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
|
||||
gaogao.scheme // => "http";
|
||||
```
|
||||
3、authority
|
||||
23、authority
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
|
||||
gaogao.authority // => "gg:gaogao@www.baidu.com:99";
|
||||
```
|
||||
4、ssp
|
||||
24、ssp
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
|
||||
gaogao.ssp " // => gg:gaogao@www.baidu.com:99/path/path?query";
|
||||
```
|
||||
5、userinfo
|
||||
25、userinfo
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
|
||||
gaogao.userinfo // => "gg:gaogao";
|
||||
```
|
||||
6、host
|
||||
26、host
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
|
||||
gaogao.host // => "www.baidu.com";
|
||||
```
|
||||
7、port
|
||||
27、port
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
|
||||
gaogao.port // => "99";
|
||||
```
|
||||
8、query
|
||||
28、query
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
|
||||
gaogao.query // => "query";
|
||||
```
|
||||
9、fragment
|
||||
29、fragment
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
|
||||
gaogao.fragment // => "fagment";
|
||||
```
|
||||
10、path
|
||||
30、path
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
|
||||
gaogao.path // => "/path/path";
|
||||
```
|
||||
11、equals(Object ob)
|
||||
31、equals(Object ob)
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment');
|
||||
let gaogao1 = gaogao;
|
||||
let res = gaogao.equals(gaogao1);
|
||||
console.log(res); // => true;
|
||||
```
|
||||
12、normalize()
|
||||
32、normalize()
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/66./../././mm/.././path1?query#fagment');
|
||||
let res = gaogao.normalize();
|
||||
console.log(res.path); // => "/path/path1"
|
||||
console.log(res.toString()); // => "http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/path1?query#fagment"
|
||||
```
|
||||
13、isAbsolute()
|
||||
33、isAbsolute()
|
||||
```
|
||||
let gaogao = new Uri.URI('f/tp://username:password@www.baidu.com:88/path?query#fagment');
|
||||
let res = gaogao.isAbsolute();
|
||||
console.log(res); //=> false;
|
||||
```
|
||||
14、toString()
|
||||
34、toString()
|
||||
```
|
||||
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment');
|
||||
let res = gaogao.toString();
|
||||
console.log(res.toString()); // => 'http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment';
|
||||
```
|
||||
|
||||
3.ConvertXml
|
||||
|
||||
1、ConvertXml()
|
||||
35、ConvertXml()
|
||||
```
|
||||
var convertml = new convertXml.ConvertXml();
|
||||
```
|
||||
2、convert(String xml, Object options)
|
||||
36、convert(String xml, Object options)
|
||||
```
|
||||
var result = convertml.convert(xml, {compact: false, spaces: 4});
|
||||
```
|
||||
@@ -347,6 +336,6 @@ var result = convertml.convert(xml, {compact: false, spaces: 4});
|
||||
|
||||
[base/compileruntime/js_api_module/](base/compileruntime/js_api_module/readme.md)
|
||||
|
||||
## 许可证
|
||||
### 许可证
|
||||
|
||||
URL在[Mozilla许可证](https://www.mozilla.org/en-US/MPL/)下可用,说明文档详见[说明文档](https://gitee.com/openharmony/js_api_module/blob/master/LICENSE_docs)。有关完整的许可证文本,请参见[许可证](https://gitee.com/openharmony/js_api_module/blob/master/LICENSE)
|
||||
URL在[Mozilla许可证](https://www.mozilla.org/en-US/MPL/)下可用,说明文档详见[说明文档](https://gitee.com/openharmony/js_api_module/blob/master/mozilla_docs.txt)。有关完整的许可证文本,有关完整的许可证文本,请参见[许可证](https://gitee.com/openharmony/js_api_module/blob/master/LICENSE)
|
||||
@@ -0,0 +1,44 @@
|
||||
|
||||
The definitions of some interfaces implemented in jsapi/api/js_url.cpp are released under Mozilla license.
|
||||
|
||||
The definitions and functions of these interfaces are consistent with the standard interfaces under mozila license,
|
||||
but the implementation of specific functions is independent and self-developed.
|
||||
|
||||
All interfaces are described in d.ts, the following is the interface written in d.ts under to Mozilla license
|
||||
|
||||
class URLSearchParams {
|
||||
|
||||
constructor(init?: string[][] | Record<string, string> | string | URLSearchParams);
|
||||
append(name: string, value: string): void;
|
||||
delete(name: string): void;
|
||||
getAll(name: string): string[];
|
||||
entries(): IterableIterator<[string, string]>;
|
||||
forEach(callbackfn: (value: string, key: string, searchParams: this) => void): void;
|
||||
get(name: string): string | null;
|
||||
has(name: string): boolean;
|
||||
set(name: string, value: string): void;
|
||||
sort(): void;
|
||||
keys(): IterableIterator<string>;
|
||||
values(): IterableIterator<string>;
|
||||
[Symbol.iterator](): IterableIterator<[string, string]>;
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
class URL {
|
||||
|
||||
constructor(url: string, base?: string | URL);
|
||||
toString(): string;
|
||||
toJSON(): string;
|
||||
hash: string;
|
||||
host: string;
|
||||
hostname: string;
|
||||
href: string;
|
||||
readonly origin: string;
|
||||
password: string;
|
||||
pathname: string;
|
||||
port: string;
|
||||
protocol: string;
|
||||
search: string;
|
||||
readonly searchParams: URLSearchParams;
|
||||
username: string;
|
||||
}
|
||||
Reference in New Issue
Block a user