Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
35a66ee1
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
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看板
未验证
提交
35a66ee1
编写于
1月 03, 2023
作者:
J
jiangkai43
提交者:
Gitee
1月 03, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
将示例代码中原构造函数修改为新的parseURL
Signed-off-by:
N
jiangkai43
<
jiangkai43@huawei.com
>
上级
1d092815
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
25 addition
and
17 deletion
+25
-17
zh-cn/application-dev/reference/apis/js-apis-url.md
zh-cn/application-dev/reference/apis/js-apis-url.md
+25
-17
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-url.md
浏览文件 @
35a66ee1
...
...
@@ -31,7 +31,7 @@ URLParams的构造函数。
let
objectParams
=
new
Url
.
URLParams
([
[
'
user1
'
,
'
abc1
'
],
[
'
query2
'
,
'
first2
'
],
[
'
query3
'
,
'
second3
'
]
]);
let
objectParams1
=
new
Url
.
URLParams
({
"
fod
"
:
'
1
'
,
"
bard
"
:
'
2
'
});
let
objectParams2
=
new
Url
.
URLParams
(
'
?fod=1&bard=2
'
);
let
urlObject
=
new
Url
.
URL
(
'
https://developer.mozilla.org/?fod=1&bard=2
'
);
let
urlObject
=
Url
.
URL
.
parse
URL
(
'
https://developer.mozilla.org/?fod=1&bard=2
'
);
let
params
=
new
Url
.
URLParams
(
urlObject
.
search
);
```
...
...
@@ -54,7 +54,7 @@ append(name: string, value: string): void
**示例:**
```
js
let
urlObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
urlObject
=
Url
.
URL
.
parse
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsObject
=
new
Url
.
URLParams
(
urlObject
.
search
.
slice
(
1
));
paramsObject
.
append
(
'
fod
'
,
'
3
'
);
```
...
...
@@ -77,7 +77,7 @@ delete(name: string): void
**示例:**
```
js
let
urlObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
urlObject
=
Url
.
URL
.
parse
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsobject
=
new
Url
.
URLParams
(
urlObject
.
search
.
slice
(
1
));
paramsobject
.
delete
(
'
fod
'
);
```
...
...
@@ -106,7 +106,7 @@ getAll(name: string): string[]
**示例:**
```
js
let
urlObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
urlObject
=
Url
.
URL
.
parse
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
params
=
new
Url
.
URLParams
(
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"].
...
...
@@ -131,7 +131,7 @@ entries(): IterableIterator<[string, string]>
```
js
let
searchParamsObject
=
new
Url
.
URLParams
(
"
keyName1=valueName1&keyName2=valueName2
"
);
for
(
var
pair
of
searchParamsObject
.
entries
())
{
// Show keyName/valueName pairs
for
(
var
pair
of
searchParamsObject
.
entries
())
{
// Show keyName/valueName pairs
console
.
log
(
pair
[
0
]
+
'
,
'
+
pair
[
1
]);
}
```
...
...
@@ -163,9 +163,9 @@ forEach(callbackFn: (value: string, key: string, searchParams: this) => void, th
**示例:**
```
js
const
myURLObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
myURLObject
.
searchP
arams
.
forEach
((
value
,
name
,
searchParams
)
=>
{
console
.
log
(
name
,
value
,
myURLObject
.
searchP
arams
===
searchParams
);
const
myURLObject
=
Url
.
URL
.
parse
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
myURLObject
.
p
arams
.
forEach
((
value
,
name
,
searchParams
)
=>
{
console
.
log
(
name
,
value
,
myURLObject
.
p
arams
===
searchParams
);
});
```
...
...
@@ -223,7 +223,7 @@ has(name: string): boolean
**示例:**
```
js
let
urlObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
urlObject
=
Url
.
URL
.
parse
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsObject
=
new
Url
.
URLParams
(
urlObject
.
search
.
slice
(
1
));
paramsObject
.
has
(
'
bard
'
)
===
true
;
```
...
...
@@ -247,7 +247,7 @@ set(name: string, value: string): void
**示例:**
```
js
let
urlObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
urlObject
=
Url
.
URL
.
parse
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsObject
=
new
Url
.
URLParams
(
urlObject
.
search
.
slice
(
1
));
paramsObject
.
set
(
'
baz
'
,
'
3
'
);
// Add a third parameter.
```
...
...
@@ -359,7 +359,7 @@ toString(): string
**示例:**
```
js
let
url
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
url
=
Url
.
URL
.
parse
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
params
=
new
Url
.
URLParams
(
url
.
search
.
slice
(
1
));
params
.
append
(
'
fod
'
,
'
3
'
);
console
.
log
(
params
.
toString
());
...
...
@@ -423,8 +423,16 @@ 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>
### constructor<sup>9+</sup>
constructor()
URL的无参构造函数。parseURL调用后返回一个URL对象,不单独使用。
**系统能力:**
SystemCapability.Utils.Lang
### parseURL<sup>9+</sup>
static parseURL(url : string, base?: string | URL): URL
URL静态成员函数。
...
...
@@ -462,7 +470,7 @@ toString(): string
**示例:**
```
js
const
url
=
new
Url
.
URL
(
'
https://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
const
url
=
Url
.
URL
.
parse
URL
(
'
https://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
url
.
toString
();
```
...
...
@@ -482,7 +490,7 @@ toJSON(): string
**示例:**
```
js
const
url
=
new
Url
.
URL
(
'
https://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
const
url
=
Url
.
URL
.
parse
URL
(
'
https://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
url
.
toJSON
();
```
...
...
@@ -660,9 +668,9 @@ forEach(callbackFn: (value: string, key: string, searchParams: this) => void, th
**示例:**
```
js
const
myURLObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
myURLObject
.
searchP
arams
.
forEach
((
value
,
name
,
searchParams
)
=>
{
console
.
log
(
name
,
value
,
myURLObject
.
searchP
arams
===
searchParams
);
const
myURLObject
=
Url
.
URL
.
parse
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
myURLObject
.
p
arams
.
forEach
((
value
,
name
,
searchParams
)
=>
{
console
.
log
(
name
,
value
,
myURLObject
.
p
arams
===
searchParams
);
});
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录