Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
1cfb1697
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1cfb1697
编写于
1月 05, 2023
作者:
O
openharmony_ci
提交者:
Gitee
1月 05, 2023
浏览文件
操作
浏览文件
下载
差异文件
!13187 将示例代码中的构造函数修改为新的parseURL函数【monthly_20221018】
Merge pull request !13187 from jiangkai43/cherry-pick-1672815679
上级
ee17b5fd
f244a3d7
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
25 addition
and
16 deletion
+25
-16
zh-cn/application-dev/reference/apis/js-apis-url.md
zh-cn/application-dev/reference/apis/js-apis-url.md
+25
-16
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-url.md
浏览文件 @
1cfb1697
...
...
@@ -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,6 +423,14 @@ 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/
```
### constructor<sup>9+</sup>
constructor()
URL的无参构造函数。parseURL调用后返回一个URL对象,不单独使用。
**系统能力:**
SystemCapability.Utils.Lang
### parseURL<sup>9+</sup>
static parseURL(url : string, base?: string | URL): URL
...
...
@@ -442,7 +450,8 @@ URL静态成员函数。
```
js
let
mm
=
'
https://username:password@host:8080
'
;
Url
.
URL
.
parseURL
(
mm
);
// Output 'https://username:password@host:8080/';
let
url
=
Url
.
URL
.
parseURL
(
mm
);
url
.
toString
();
// Output 'https://username:password@host:8080/';
```
### tostring
...
...
@@ -462,7 +471,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 +491,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
();
```
...
...
@@ -624,7 +633,7 @@ entries(): IterableIterator<[string, string]>
```
js
let
searchParamsObject
=
new
Url
.
URLSearchParams
(
"
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
]);
}
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录