Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
f7fd1f34
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f7fd1f34
编写于
10月 13, 2022
作者:
G
Gloria
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update docs against 10317+10328
Signed-off-by: wusongqing<wusongqing@huawei.com>
上级
0b79ec67
变更
2
展开全部
显示空白变更内容
内联
并排
Showing
2 changed file
with
203 addition
and
158 deletion
+203
-158
en/application-dev/reference/apis/js-apis-Context.md
en/application-dev/reference/apis/js-apis-Context.md
+172
-126
en/application-dev/reference/apis/js-apis-url.md
en/application-dev/reference/apis/js-apis-url.md
+31
-32
未找到文件。
en/application-dev/reference/apis/js-apis-Context.md
浏览文件 @
f7fd1f34
此差异已折叠。
点击以展开。
en/application-dev/reference/apis/js-apis-url.md
浏览文件 @
f7fd1f34
...
...
@@ -26,16 +26,16 @@ Creates a **URLSearchParams** instance.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| init | string
[][]
\|
Record
<
string, string
>
\|
string
\|
URLSearchParams | No| Input parameter objects, which include the following:
<br>
-
**string[][]**
: two-dimensional string array
<br>
-
**Record<string, string>**
: list of objects
<br>
-
**string**
: string
<br>
-
**URLSearchParams**
: object
|
| init | string
[][]
\|
Record
<
string, string
>
\|
string
\|
URLSearchParams | No| Input parameter objects, which include the following:
<br>
-
**string[][]**
: two-dimensional string array
<br>
-
**Record<string, string>**
: list of objects
<br>
-
**string**
: string
<br>
-
**URLSearchParams**
: object|
**Example**
```
js
var
objectParams
=
new
Url
.
URLSearchParams
([
[
'
user1
'
,
'
abc1
'
],
[
'
query2
'
,
'
first2
'
],
[
'
query3
'
,
'
second3
'
]
]);
var
objectParams1
=
new
Url
.
URLSearchParams
({
"
fod
"
:
1
,
"
bard
"
:
2
});
var
objectParams2
=
new
Url
.
URLSearchParams
(
'
?fod=1&bard=2
'
);
var
urlObject
=
new
Url
.
URL
(
'
https://developer.mozilla.org/?fod=1&bard=2
'
);
var
params
=
new
Url
.
URLSearchParams
(
urlObject
.
search
);
let
objectParams
=
new
Url
.
URLSearchParams
([
[
'
user1
'
,
'
abc1
'
],
[
'
query2
'
,
'
first2
'
],
[
'
query3
'
,
'
second3
'
]
]);
let
objectParams1
=
new
Url
.
URLSearchParams
({
"
fod
"
:
'
1
'
,
"
bard
"
:
'
2
'
});
let
objectParams2
=
new
Url
.
URLSearchParams
(
'
?fod=1&bard=2
'
);
let
urlObject
=
new
Url
.
URL
(
'
https://developer.mozilla.org/?fod=1&bard=2
'
);
let
params
=
new
Url
.
URLSearchParams
(
urlObject
.
search
);
```
...
...
@@ -59,7 +59,7 @@ Appends a key-value pair into the query string.
```
js
let
urlObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsObject
=
new
Url
.
URLSearchParams
(
urlObject
.
search
.
slice
(
1
));
paramsObject
.
append
(
'
fod
'
,
3
);
paramsObject
.
append
(
'
fod
'
,
'
3
'
);
```
...
...
@@ -110,9 +110,9 @@ Obtains all the key-value pairs based on the specified key.
```
js
let
urlObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
params
Object
=
new
Url
.
URLSearchParams
(
urlObject
.
search
.
slice
(
1
));
params
Object
.
append
(
'
fod
'
,
3
);
// Add a second value for the fod parameter.
console
.
log
(
params
.
getAll
(
'
fod
'
))
// Output ["1","3"].
let
params
=
new
Url
.
URLSearchParams
(
urlObject
.
search
.
slice
(
1
));
params
.
append
(
'
fod
'
,
'
3
'
);
// Add a second value for the fod parameter.
console
.
log
(
params
.
getAll
(
'
fod
'
)
.
toString
()
)
// Output ["1","3"].
```
...
...
@@ -133,7 +133,7 @@ Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and th
**Example**
```
js
var
searchParamsObject
=
new
Url
.
URLSearchParams
(
"
keyName1=valueName1&keyName2=valueName2
"
);
let
searchParamsObject
=
new
Url
.
URLSearchParams
(
"
keyName1=valueName1&keyName2=valueName2
"
);
for
(
var
pair
of
searchParamsObject
.
entries
())
{
// Show keyName/valueName pairs
console
.
log
(
pair
[
0
]
+
'
,
'
+
pair
[
1
]);
}
...
...
@@ -192,15 +192,14 @@ Obtains the value of the first key-value pair based on the specified key.
| Type | Description |
| -------- | -------- |
| string | Returns the value of the first key-value pair if obtained. |
| null | Returns
null if no value is obtained.
|
| null | Returns
**null**
if no value is obtained.
|
**Example**
```
js
var
paramsOject
=
new
Url
.
URLSearchParams
(
document
.
location
.
search
.
substring
(
1
));
var
name
=
paramsOject
.
get
(
"
name
"
);
// is the string "Jonathan"
var
age
=
parseInt
(
paramsOject
.
get
(
"
age
"
),
10
);
// is the number 18
var
address
=
paramsOject
.
get
(
"
address
"
);
// null
let
paramsObject
=
new
Url
.
URLSearchParams
(
'
name=Jonathan&age=18
'
);
let
name
=
paramsObject
.
get
(
"
name
"
);
// is the string "Jonathan"
let
age
=
parseInt
(
paramsObject
.
get
(
"
age
"
),
10
);
// is the number 18
```
...
...
@@ -253,7 +252,7 @@ Sets the value for a key. If key-value pairs matching the specified key exist, t
```
js
let
urlObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsObject
=
new
Url
.
URLSearchParams
(
urlObject
.
search
.
slice
(
1
));
paramsObject
.
set
(
'
baz
'
,
3
);
// Add a third parameter.
paramsObject
.
set
(
'
baz
'
,
'
3
'
);
// Add a third parameter.
```
...
...
@@ -268,7 +267,7 @@ Sorts all key-value pairs contained in this object based on the Unicode code poi
**Example**
```
js
var
searchParamsObject
=
new
Url
.
URLSearchParams
(
"
c=3&a=9&b=4&d=2
"
);
// Create a test URLSearchParams object
let
searchParamsObject
=
new
Url
.
URLSearchParams
(
"
c=3&a=9&b=4&d=2
"
);
// Create a test URLSearchParams object
searchParamsObject
.
sort
();
// Sort the key/value pairs
console
.
log
(
searchParamsObject
.
toString
());
// Display the sorted query string // Output a=9&b=2&c=3&d=4
```
...
...
@@ -291,7 +290,7 @@ Obtains an ES6 iterator that contains the keys of all the key-value pairs.
**Example**
```
js
var
searchParamsObject
=
new
Url
.
URLSearchParams
(
"
key1=value1&key2=value2
"
);
// Create a URLSearchParamsObject object for testing
let
searchParamsObject
=
new
Url
.
URLSearchParams
(
"
key1=value1&key2=value2
"
);
// Create a URLSearchParamsObject object for testing
for
(
var
key
of
searchParamsObject
.
keys
())
{
// Output key-value pairs
console
.
log
(
key
);
}
...
...
@@ -315,7 +314,7 @@ Obtains an ES6 iterator that contains the values of all the key-value pairs.
**Example**
```
js
var
searchParams
=
new
Url
.
URLSearchParams
(
"
key1=value1&key2=value2
"
);
// Create a URLSearchParamsObject object for testing
let
searchParams
=
new
Url
.
URLSearchParams
(
"
key1=value1&key2=value2
"
);
// Create a URLSearchParamsObject object for testing
for
(
var
value
of
searchParams
.
values
())
{
console
.
log
(
value
);
}
...
...
@@ -365,7 +364,7 @@ Obtains search parameters that are serialized as a string and, if necessary, per
```
js
let
url
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
params
=
new
Url
.
URLSearchParams
(
url
.
search
.
slice
(
1
));
params
.
append
(
'
fod
'
,
3
);
params
.
append
(
'
fod
'
,
'
3
'
);
console
.
log
(
params
.
toString
());
```
...
...
@@ -405,16 +404,16 @@ Creates a URL.
| 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
|
| base | string
\
|
URL | No| Input parameter, which can be any of the following:
<br>
-
**string**
: string
<br>
-
**URL**
: string or object
|
**Example**
```
js
var
mm
=
'
http://username:password@host:8080
'
;
var
a
=
new
Url
.
URL
(
"
/
"
,
mm
);
// Output 'http://username:password@host:8080/';
var
b
=
new
Url
.
URL
(
mm
);
// Output 'http://username:password@host:8080/';
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';
var
c
=
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
...
...
@@ -443,7 +442,7 @@ Converts the parsed URL into a string.
```
js
const
url
=
new
Url
.
URL
(
'
http://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
url
.
toString
()
url
.
toString
()
;
```
...
...
@@ -464,5 +463,5 @@ 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
'
);
url
.
toJSON
()
url
.
toJSON
()
;
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录