Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
ce33b186
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看板
提交
ce33b186
编写于
9月 05, 2023
作者:
J
jiangkai43
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
公共库示例代码适配ArkTs
Signed-off-by:
N
jiangkai43
<
jiangkai43@huawei.com
>
上级
ba0e70f1
变更
4
展开全部
显示空白变更内容
内联
并排
Showing
4 changed file
with
259 addition
and
290 deletion
+259
-290
zh-cn/application-dev/reference/apis/js-apis-convertxml.md
zh-cn/application-dev/reference/apis/js-apis-convertxml.md
+27
-27
zh-cn/application-dev/reference/apis/js-apis-uri.md
zh-cn/application-dev/reference/apis/js-apis-uri.md
+11
-11
zh-cn/application-dev/reference/apis/js-apis-url.md
zh-cn/application-dev/reference/apis/js-apis-url.md
+70
-58
zh-cn/application-dev/reference/apis/js-apis-xml.md
zh-cn/application-dev/reference/apis/js-apis-xml.md
+151
-194
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-convertxml.md
浏览文件 @
ce33b186
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
## 导入模块
## 导入模块
```
j
s
```
t
s
import
convertxml
from
'
@ohos.convertxml
'
;
import
convertxml
from
'
@ohos.convertxml
'
;
```
```
...
@@ -46,7 +46,7 @@ convertToJSObject(xml: string, options?: ConvertOptions) : Object
...
@@ -46,7 +46,7 @@ convertToJSObject(xml: string, options?: ConvertOptions) : Object
**示例:**
**示例:**
```
j
s
```
t
s
try
{
try
{
let
xml
=
let
xml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<?xml version="1.0" encoding="utf-8"?>
'
+
...
@@ -56,7 +56,7 @@ try {
...
@@ -56,7 +56,7 @@ try {
'
<todo>Play</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
'
</note>
'
;
let
conv
=
new
convertxml
.
ConvertXML
()
let
conv
=
new
convertxml
.
ConvertXML
()
let
o
ptions
=
{
let
options
:
convertxml
.
ConvertO
ptions
=
{
trim
:
false
,
declarationKey
:
"
_declaration
"
,
trim
:
false
,
declarationKey
:
"
_declaration
"
,
instructionKey
:
"
_instruction
"
,
attributesKey
:
"
_attributes
"
,
instructionKey
:
"
_instruction
"
,
attributesKey
:
"
_attributes
"
,
textKey
:
"
_text
"
,
cdataKey
:
"
_cdata
"
,
doctypeKey
:
"
_doctype
"
,
textKey
:
"
_text
"
,
cdataKey
:
"
_cdata
"
,
doctypeKey
:
"
_doctype
"
,
...
@@ -99,7 +99,7 @@ convert(xml: string, options?: ConvertOptions) : Object
...
@@ -99,7 +99,7 @@ convert(xml: string, options?: ConvertOptions) : Object
**示例:**
**示例:**
```
j
s
```
t
s
let
xml
=
let
xml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
'
<note importance="high" logged="true">
'
+
...
@@ -108,7 +108,7 @@ let xml =
...
@@ -108,7 +108,7 @@ let xml =
'
<todo>Play</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
'
</note>
'
;
let
conv
=
new
convertxml
.
ConvertXML
();
let
conv
=
new
convertxml
.
ConvertXML
();
let
options
=
{
trim
:
false
,
declarationKey
:
"
_declaration
"
,
let
options
:
convertxml
.
ConvertOptions
=
{
trim
:
false
,
declarationKey
:
"
_declaration
"
,
instructionKey
:
"
_instruction
"
,
attributesKey
:
"
_attributes
"
,
instructionKey
:
"
_instruction
"
,
attributesKey
:
"
_attributes
"
,
textKey
:
"
_text
"
,
cdataKey
:
"
_cdata
"
,
doctypeKey
:
"
_doctype
"
,
textKey
:
"
_text
"
,
cdataKey
:
"
_cdata
"
,
doctypeKey
:
"
_doctype
"
,
commentKey
:
"
_comment
"
,
parentKey
:
"
_parent
"
,
typeKey
:
"
_type
"
,
commentKey
:
"
_comment
"
,
parentKey
:
"
_parent
"
,
typeKey
:
"
_type
"
,
...
...
zh-cn/application-dev/reference/apis/js-apis-uri.md
浏览文件 @
ce33b186
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
## 导入模块
## 导入模块
```
j
s
```
t
s
import
uri
from
'
@ohos.uri
'
import
uri
from
'
@ohos.uri
'
```
```
...
@@ -47,7 +47,7 @@ import uri from '@ohos.uri'
...
@@ -47,7 +47,7 @@ import uri from '@ohos.uri'
**URI示例:**
**URI示例:**
```
j
s
```
t
s
const
result1
=
new
uri
.
URI
(
"
ftp://ftp.aaa.bbb.ccc/dddd/eee.txt
"
);
const
result1
=
new
uri
.
URI
(
"
ftp://ftp.aaa.bbb.ccc/dddd/eee.txt
"
);
console
.
log
(
result1
.
host
)
// ftp.aaa.bbb.ccc
console
.
log
(
result1
.
host
)
// ftp.aaa.bbb.ccc
console
.
log
(
result1
.
fragment
)
// null
console
.
log
(
result1
.
fragment
)
// null
...
@@ -118,12 +118,12 @@ constructor是URI的构造函数。
...
@@ -118,12 +118,12 @@ constructor是URI的构造函数。
**示例:**
**示例:**
```
j
s
```
t
s
let
mm
=
'
https://username:password@host:8080/directory/file?foo=1&bar=2#fragment
'
;
let
mm
=
'
https://username:password@host:8080/directory/file?foo=1&bar=2#fragment
'
;
new
uri
.
URI
(
mm
);
// Output 'https://username:password@host:8080/directory/file?foo=1&bar=2#fragment';
new
uri
.
URI
(
mm
);
```
```
```
j
s
```
t
s
new
uri
.
URI
(
'
https://username:password@host:8080
'
);
// Output 'https://username:password@host:8080';
new
uri
.
URI
(
'
https://username:password@host:8080
'
);
```
```
...
@@ -143,7 +143,7 @@ toString(): string
...
@@ -143,7 +143,7 @@ toString(): string
**示例:**
**示例:**
```
j
s
```
t
s
const
result
=
new
uri
.
URI
(
'
https://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
const
result
=
new
uri
.
URI
(
'
https://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
let
result1
=
result
.
toString
();
let
result1
=
result
.
toString
();
```
```
...
@@ -175,7 +175,7 @@ equals(other: URI): boolean
...
@@ -175,7 +175,7 @@ equals(other: URI): boolean
**示例:**
**示例:**
```
j
s
```
t
s
const
uriInstance
=
new
uri
.
URI
(
'
https://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
const
uriInstance
=
new
uri
.
URI
(
'
https://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
const
uriInstance1
=
new
uri
.
URI
(
'
https://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
const
uriInstance1
=
new
uri
.
URI
(
'
https://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
uriInstance
.
equals
(
uriInstance1
);
uriInstance
.
equals
(
uriInstance1
);
...
@@ -202,7 +202,7 @@ equalsTo(other: URI): boolean
...
@@ -202,7 +202,7 @@ equalsTo(other: URI): boolean
**示例:**
**示例:**
```
j
s
```
t
s
const
uriInstance
=
new
uri
.
URI
(
'
https://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
const
uriInstance
=
new
uri
.
URI
(
'
https://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
const
uriInstance1
=
new
uri
.
URI
(
'
https://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
const
uriInstance1
=
new
uri
.
URI
(
'
https://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
let
result
=
uriInstance
.
equalsTo
(
uriInstance1
);
let
result
=
uriInstance
.
equalsTo
(
uriInstance1
);
...
@@ -224,7 +224,7 @@ checkIsAbsolute(): boolean
...
@@ -224,7 +224,7 @@ checkIsAbsolute(): boolean
**示例:**
**示例:**
```
j
s
```
t
s
const
uriInstance
=
new
uri
.
URI
(
'
https://username:password@www.qwer.com:8080?query=pppppp
'
);
const
uriInstance
=
new
uri
.
URI
(
'
https://username:password@www.qwer.com:8080?query=pppppp
'
);
console
.
log
(
`
${
uriInstance
.
checkIsAbsolute
()}
`
);
// true
console
.
log
(
`
${
uriInstance
.
checkIsAbsolute
()}
`
);
// true
const
uriInstance1
=
new
uri
.
URI
(
'
xxx.com/suppliers.htm
'
);
const
uriInstance1
=
new
uri
.
URI
(
'
xxx.com/suppliers.htm
'
);
...
@@ -248,7 +248,7 @@ normalize(): URI
...
@@ -248,7 +248,7 @@ normalize(): URI
**示例:**
**示例:**
```
j
s
```
t
s
const
uriInstance
=
new
uri
.
URI
(
'
https://username:password@www.qwer.com:8080/path/path1/../path2/./path3?query=pppppp
'
);
const
uriInstance
=
new
uri
.
URI
(
'
https://username:password@www.qwer.com:8080/path/path1/../path2/./path3?query=pppppp
'
);
console
.
log
(
uriInstance
.
path
);
// /path/path1/../path2/./path3
console
.
log
(
uriInstance
.
path
);
// /path/path1/../path2/./path3
let
uriInstance1
=
uriInstance
.
normalize
();
let
uriInstance1
=
uriInstance
.
normalize
();
...
...
zh-cn/application-dev/reference/apis/js-apis-url.md
浏览文件 @
ce33b186
...
@@ -27,7 +27,7 @@ URLParams的构造函数。
...
@@ -27,7 +27,7 @@ URLParams的构造函数。
**示例:**
**示例:**
```
j
s
```
t
s
let
objectParams
=
new
Url
.
URLParams
([
[
'
user1
'
,
'
abc1
'
],
[
'
query2
'
,
'
first2
'
],
[
'
query3
'
,
'
second3
'
]
]);
let
objectParams
=
new
Url
.
URLParams
([
[
'
user1
'
,
'
abc1
'
],
[
'
query2
'
,
'
first2
'
],
[
'
query3
'
,
'
second3
'
]
]);
let
objectParams1
=
new
Url
.
URLParams
({
"
fod
"
:
'
1
'
,
"
bard
"
:
'
2
'
});
let
objectParams1
=
new
Url
.
URLParams
({
"
fod
"
:
'
1
'
,
"
bard
"
:
'
2
'
});
let
objectParams2
=
new
Url
.
URLParams
(
'
?fod=1&bard=2
'
);
let
objectParams2
=
new
Url
.
URLParams
(
'
?fod=1&bard=2
'
);
...
@@ -53,7 +53,7 @@ append(name: string, value: string): void
...
@@ -53,7 +53,7 @@ append(name: string, value: string): void
**示例:**
**示例:**
```
j
s
```
t
s
let
urlObject
=
Url
.
URL
.
parseURL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
urlObject
=
Url
.
URL
.
parseURL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsObject
=
new
Url
.
URLParams
(
urlObject
.
search
.
slice
(
1
));
let
paramsObject
=
new
Url
.
URLParams
(
urlObject
.
search
.
slice
(
1
));
paramsObject
.
append
(
'
fod
'
,
'
3
'
);
paramsObject
.
append
(
'
fod
'
,
'
3
'
);
...
@@ -76,7 +76,7 @@ delete(name: string): void
...
@@ -76,7 +76,7 @@ delete(name: string): void
**示例:**
**示例:**
```
j
s
```
t
s
let
urlObject
=
Url
.
URL
.
parseURL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
urlObject
=
Url
.
URL
.
parseURL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsObject
=
new
Url
.
URLParams
(
urlObject
.
search
.
slice
(
1
));
let
paramsObject
=
new
Url
.
URLParams
(
urlObject
.
search
.
slice
(
1
));
paramsObject
.
delete
(
'
fod
'
);
paramsObject
.
delete
(
'
fod
'
);
...
@@ -105,7 +105,7 @@ getAll(name: string): string[]
...
@@ -105,7 +105,7 @@ getAll(name: string): string[]
**示例:**
**示例:**
```
j
s
```
t
s
let
urlObject
=
Url
.
URL
.
parseURL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
urlObject
=
Url
.
URL
.
parseURL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
params
=
new
Url
.
URLParams
(
urlObject
.
search
.
slice
(
1
));
let
params
=
new
Url
.
URLParams
(
urlObject
.
search
.
slice
(
1
));
params
.
append
(
'
fod
'
,
'
3
'
);
// Add a second value for the fod parameter.
params
.
append
(
'
fod
'
,
'
3
'
);
// Add a second value for the fod parameter.
...
@@ -129,9 +129,11 @@ entries(): IterableIterator<[string, string]>
...
@@ -129,9 +129,11 @@ entries(): IterableIterator<[string, string]>
**示例:**
**示例:**
```
j
s
```
t
s
let
searchParamsObject
=
new
Url
.
URLParams
(
"
keyName1=valueName1&keyName2=valueName2
"
);
let
searchParamsObject
=
new
Url
.
URLParams
(
"
keyName1=valueName1&keyName2=valueName2
"
);
for
(
var
pair
of
searchParamsObject
.
entries
())
{
// Show keyName/valueName pairs
let
pair
:
Iterable
<
Object
[]
>
=
searchParamsObject
.
entries
();
let
arrayValue
=
Array
.
from
(
pair
);
for
(
let
pair
of
arrayValue
)
{
// Show keyName/valueName pairs
console
.
log
(
pair
[
0
]
+
'
,
'
+
pair
[
1
]);
console
.
log
(
pair
[
0
]
+
'
,
'
+
pair
[
1
]);
}
}
```
```
...
@@ -162,7 +164,7 @@ forEach(callbackFn: (value: string, key: string, searchParams: this) => void, th
...
@@ -162,7 +164,7 @@ forEach(callbackFn: (value: string, key: string, searchParams: this) => void, th
**示例:**
**示例:**
```
j
s
```
t
s
const
myURLObject
=
Url
.
URL
.
parseURL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
const
myURLObject
=
Url
.
URL
.
parseURL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
myURLObject
.
params
.
forEach
((
value
,
name
,
searchParams
)
=>
{
myURLObject
.
params
.
forEach
((
value
,
name
,
searchParams
)
=>
{
console
.
log
(
name
,
value
,
myURLObject
.
params
===
searchParams
);
console
.
log
(
name
,
value
,
myURLObject
.
params
===
searchParams
);
...
@@ -193,10 +195,10 @@ get(name: string): string | null
...
@@ -193,10 +195,10 @@ get(name: string): string | null
**示例:**
**示例:**
```
j
s
```
t
s
let
paramsObject
=
new
Url
.
URLParams
(
'
name=Jonathan&age=18
'
);
let
paramsObject
=
new
Url
.
URLParams
(
'
name=Jonathan&age=18
'
);
let
name
=
paramsObject
.
get
(
"
name
"
);
// is the string "Jonathan"
let
name
=
paramsObject
.
get
(
"
name
"
);
// is the string "Jonathan"
let
age
=
par
seInt
(
paramsObject
.
get
(
"
age
"
),
10
);
// is the number 18
let
age
=
par
amsObject
.
get
(
"
age
"
);
// is the string "18"
```
```
...
@@ -222,7 +224,7 @@ has(name: string): boolean
...
@@ -222,7 +224,7 @@ has(name: string): boolean
**示例:**
**示例:**
```
j
s
```
t
s
let
urlObject
=
Url
.
URL
.
parseURL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
urlObject
=
Url
.
URL
.
parseURL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsObject
=
new
Url
.
URLParams
(
urlObject
.
search
.
slice
(
1
));
let
paramsObject
=
new
Url
.
URLParams
(
urlObject
.
search
.
slice
(
1
));
let
result
=
paramsObject
.
has
(
'
bard
'
);
let
result
=
paramsObject
.
has
(
'
bard
'
);
...
@@ -246,7 +248,7 @@ set(name: string, value: string): void
...
@@ -246,7 +248,7 @@ set(name: string, value: string): void
**示例:**
**示例:**
```
j
s
```
t
s
let
urlObject
=
Url
.
URL
.
parseURL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
urlObject
=
Url
.
URL
.
parseURL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsObject
=
new
Url
.
URLParams
(
urlObject
.
search
.
slice
(
1
));
let
paramsObject
=
new
Url
.
URLParams
(
urlObject
.
search
.
slice
(
1
));
paramsObject
.
set
(
'
baz
'
,
'
3
'
);
// Add a third parameter.
paramsObject
.
set
(
'
baz
'
,
'
3
'
);
// Add a third parameter.
...
@@ -263,10 +265,10 @@ sort(): void
...
@@ -263,10 +265,10 @@ sort(): void
**示例:**
**示例:**
```
j
s
```
t
s
let
searchParamsObject
=
new
Url
.
URLParams
(
"
c=3&a=9&b=4&d=2
"
);
// Create a test URLSearchParams object
let
searchParamsObject
=
new
Url
.
URLParams
(
"
c=3&a=9&b=4&d=2
"
);
// Create a test URLSearchParams object
searchParamsObject
.
sort
();
// Sort the key/value pairs
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
console
.
log
(
searchParamsObject
.
toString
());
// Display the sorted query string // Output a=9&b=
4&c=3&d=2
```
```
...
@@ -286,9 +288,10 @@ keys(): IterableIterator<string>
...
@@ -286,9 +288,10 @@ keys(): IterableIterator<string>
**示例:**
**示例:**
```
j
s
```
t
s
let
searchParamsObject
=
new
Url
.
URLParams
(
"
key1=value1&key2=value2
"
);
// Create a URLSearchParamsObject object for testing
let
searchParamsObject
=
new
Url
.
URLParams
(
"
key1=value1&key2=value2
"
);
// Create a URLSearchParamsObject object for testing
for
(
var
key
of
searchParamsObject
.
keys
())
{
// Output key-value pairs
let
keys
=
Array
.
from
(
searchParamsObject
.
keys
());
for
(
let
key
of
keys
)
{
// Output key-value pairs
console
.
log
(
key
);
console
.
log
(
key
);
}
}
```
```
...
@@ -310,9 +313,10 @@ values(): IterableIterator<string>
...
@@ -310,9 +313,10 @@ values(): IterableIterator<string>
**示例:**
**示例:**
```
j
s
```
t
s
let
searchParams
=
new
Url
.
URLParams
(
"
key1=value1&key2=value2
"
);
// Create a URLSearchParamsObject object for testing
let
searchParams
=
new
Url
.
URLParams
(
"
key1=value1&key2=value2
"
);
// Create a URLSearchParamsObject object for testing
for
(
var
value
of
searchParams
.
values
())
{
let
values
=
Array
.
from
(
searchParams
.
values
());
for
(
let
value
of
values
)
{
console
.
log
(
value
);
console
.
log
(
value
);
}
}
```
```
...
@@ -334,10 +338,12 @@ for (var value of searchParams.values()) {
...
@@ -334,10 +338,12 @@ for (var value of searchParams.values()) {
**示例:**
**示例:**
```
j
s
```
t
s
const
paramsObject
=
new
Url
.
URLParams
(
'
fod=bay&edg=bap
'
);
const
paramsObject
=
new
Url
.
URLParams
(
'
fod=bay&edg=bap
'
);
for
(
const
[
name
,
value
]
of
paramsObject
[
Symbol
.
iterator
]())
{
let
iter
:
Iterable
<
Object
[]
>
=
paramsObject
[
Symbol
.
iterator
]();
console
.
log
(
name
,
value
);
let
pairs
=
Array
.
from
(
iter
);
for
(
let
pair
of
pairs
)
{
console
.
log
(
pair
[
0
]
+
'
,
'
+
pair
[
1
]);
}
}
```
```
...
@@ -358,7 +364,7 @@ toString(): string
...
@@ -358,7 +364,7 @@ toString(): string
**示例:**
**示例:**
```
j
s
```
t
s
let
url
=
Url
.
URL
.
parseURL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
url
=
Url
.
URL
.
parseURL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
params
=
new
Url
.
URLParams
(
url
.
search
.
slice
(
1
));
let
params
=
new
Url
.
URLParams
(
url
.
search
.
slice
(
1
));
params
.
append
(
'
fod
'
,
'
3
'
);
params
.
append
(
'
fod
'
,
'
3
'
);
...
@@ -408,7 +414,7 @@ URL的构造函数。
...
@@ -408,7 +414,7 @@ URL的构造函数。
**示例:**
**示例:**
```
j
s
```
t
s
let
mm
=
'
https://username:password@host:8080
'
;
let
mm
=
'
https://username:password@host:8080
'
;
let
a
=
new
Url
.
URL
(
"
/
"
,
mm
);
// Output '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/';
let
b
=
new
Url
.
URL
(
mm
);
// Output 'https://username:password@host:8080/';
...
@@ -457,7 +463,7 @@ URL静态成员函数。
...
@@ -457,7 +463,7 @@ URL静态成员函数。
**示例:**
**示例:**
```
j
s
```
t
s
let
mm
=
'
https://username:password@host:8080
'
;
let
mm
=
'
https://username:password@host:8080
'
;
let
url
=
Url
.
URL
.
parseURL
(
mm
);
let
url
=
Url
.
URL
.
parseURL
(
mm
);
let
result
=
url
.
toString
();
// Output 'https://username:password@host:8080/'
let
result
=
url
.
toString
();
// Output 'https://username:password@host:8080/'
...
@@ -479,7 +485,7 @@ toString(): string
...
@@ -479,7 +485,7 @@ toString(): string
**示例:**
**示例:**
```
j
s
```
t
s
const
url
=
Url
.
URL
.
parseURL
(
'
https://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
const
url
=
Url
.
URL
.
parseURL
(
'
https://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
let
result
=
url
.
toString
();
let
result
=
url
.
toString
();
```
```
...
@@ -499,7 +505,7 @@ toJSON(): string
...
@@ -499,7 +505,7 @@ toJSON(): string
| string | 用于返回网址的字符串序列化。 |
| string | 用于返回网址的字符串序列化。 |
**示例:**
**示例:**
```
j
s
```
t
s
const
url
=
Url
.
URL
.
parseURL
(
'
https://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
const
url
=
Url
.
URL
.
parseURL
(
'
https://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
let
result
=
url
.
toJSON
();
let
result
=
url
.
toJSON
();
```
```
...
@@ -526,7 +532,7 @@ URLSearchParams的构造函数。
...
@@ -526,7 +532,7 @@ URLSearchParams的构造函数。
**示例:**
**示例:**
```
j
s
```
t
s
let
objectParams
=
new
Url
.
URLSearchParams
([
[
'
user1
'
,
'
abc1
'
],
[
'
query2
'
,
'
first2
'
],
[
'
query3
'
,
'
second3
'
]
]);
let
objectParams
=
new
Url
.
URLSearchParams
([
[
'
user1
'
,
'
abc1
'
],
[
'
query2
'
,
'
first2
'
],
[
'
query3
'
,
'
second3
'
]
]);
let
objectParams1
=
new
Url
.
URLSearchParams
({
"
fod
"
:
'
1
'
,
"
bard
"
:
'
2
'
});
let
objectParams1
=
new
Url
.
URLSearchParams
({
"
fod
"
:
'
1
'
,
"
bard
"
:
'
2
'
});
let
objectParams2
=
new
Url
.
URLSearchParams
(
'
?fod=1&bard=2
'
);
let
objectParams2
=
new
Url
.
URLSearchParams
(
'
?fod=1&bard=2
'
);
...
@@ -555,7 +561,7 @@ append(name: string, value: string): void
...
@@ -555,7 +561,7 @@ append(name: string, value: string): void
**示例:**
**示例:**
```
j
s
```
t
s
let
urlObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
urlObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsObject
=
new
Url
.
URLSearchParams
(
urlObject
.
search
.
slice
(
1
));
let
paramsObject
=
new
Url
.
URLSearchParams
(
urlObject
.
search
.
slice
(
1
));
paramsObject
.
append
(
'
fod
'
,
'
3
'
);
paramsObject
.
append
(
'
fod
'
,
'
3
'
);
...
@@ -581,7 +587,7 @@ delete(name: string): void
...
@@ -581,7 +587,7 @@ delete(name: string): void
**示例:**
**示例:**
```
j
s
```
t
s
let
urlObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
urlObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsobject
=
new
Url
.
URLSearchParams
(
urlObject
.
search
.
slice
(
1
));
let
paramsobject
=
new
Url
.
URLSearchParams
(
urlObject
.
search
.
slice
(
1
));
paramsobject
.
delete
(
'
fod
'
);
paramsobject
.
delete
(
'
fod
'
);
...
@@ -613,7 +619,7 @@ getAll(name: string): string[]
...
@@ -613,7 +619,7 @@ getAll(name: string): string[]
**示例:**
**示例:**
```
j
s
```
t
s
let
urlObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
urlObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
params
=
new
Url
.
URLSearchParams
(
urlObject
.
search
.
slice
(
1
));
let
params
=
new
Url
.
URLSearchParams
(
urlObject
.
search
.
slice
(
1
));
params
.
append
(
'
fod
'
,
'
3
'
);
// Add a second value for the fod parameter.
params
.
append
(
'
fod
'
,
'
3
'
);
// Add a second value for the fod parameter.
...
@@ -640,9 +646,11 @@ entries(): IterableIterator<[string, string]>
...
@@ -640,9 +646,11 @@ entries(): IterableIterator<[string, string]>
**示例:**
**示例:**
```
j
s
```
t
s
let
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
let
iter
:
Iterable
<
Object
[]
>
=
searchParamsObject
.
entries
();
let
pairs
=
Array
.
from
(
iter
);
for
(
let
pair
of
pairs
)
{
// Show keyName/valueName pairs
console
.
log
(
pair
[
0
]
+
'
,
'
+
pair
[
1
]);
console
.
log
(
pair
[
0
]
+
'
,
'
+
pair
[
1
]);
}
}
```
```
...
@@ -677,7 +685,7 @@ forEach(callbackFn: (value: string, key: string, searchParams: this) => void, th
...
@@ -677,7 +685,7 @@ forEach(callbackFn: (value: string, key: string, searchParams: this) => void, th
**示例:**
**示例:**
```
j
s
```
t
s
const
myURLObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
const
myURLObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
myURLObject
.
searchParams
.
forEach
((
value
,
name
,
searchParams
)
=>
{
myURLObject
.
searchParams
.
forEach
((
value
,
name
,
searchParams
)
=>
{
console
.
log
(
name
,
value
,
myURLObject
.
searchParams
===
searchParams
);
console
.
log
(
name
,
value
,
myURLObject
.
searchParams
===
searchParams
);
...
@@ -712,10 +720,10 @@ get(name: string): string | null
...
@@ -712,10 +720,10 @@ get(name: string): string | null
**示例:**
**示例:**
```
j
s
```
t
s
let
paramsObject
=
new
Url
.
URLSearchParams
(
'
name=Jonathan&age=18
'
);
let
paramsObject
=
new
Url
.
URLSearchParams
(
'
name=Jonathan&age=18
'
);
let
name
=
paramsObject
.
get
(
"
name
"
);
// is the string "Jonathan"
let
name
=
paramsObject
.
get
(
"
name
"
);
// is the string "Jonathan"
let
age
=
par
seInt
(
paramsObject
.
get
(
"
age
"
),
10
);
// is the number 18
let
age
=
par
amsObject
.
get
(
"
age
"
);
// is the string '18'
```
```
...
@@ -745,7 +753,7 @@ has(name: string): boolean
...
@@ -745,7 +753,7 @@ has(name: string): boolean
**示例:**
**示例:**
```
j
s
```
t
s
let
urlObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
urlObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsObject
=
new
Url
.
URLSearchParams
(
urlObject
.
search
.
slice
(
1
));
let
paramsObject
=
new
Url
.
URLSearchParams
(
urlObject
.
search
.
slice
(
1
));
paramsObject
.
has
(
'
bard
'
)
===
true
;
paramsObject
.
has
(
'
bard
'
)
===
true
;
...
@@ -773,7 +781,7 @@ set(name: string, value: string): void
...
@@ -773,7 +781,7 @@ set(name: string, value: string): void
**示例:**
**示例:**
```
j
s
```
t
s
let
urlObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
urlObject
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsObject
=
new
Url
.
URLSearchParams
(
urlObject
.
search
.
slice
(
1
));
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.
...
@@ -794,10 +802,10 @@ sort(): void
...
@@ -794,10 +802,10 @@ sort(): void
**示例:**
**示例:**
```
j
s
```
t
s
let
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
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
console
.
log
(
searchParamsObject
.
toString
());
// Display the sorted query string // Output a=9&b=
4&c=3&d=2
```
```
...
@@ -821,9 +829,10 @@ keys(): IterableIterator<string>
...
@@ -821,9 +829,10 @@ keys(): IterableIterator<string>
**示例:**
**示例:**
```
j
s
```
t
s
let
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
let
keys
=
Array
.
from
(
searchParamsObject
.
keys
());
for
(
let
key
of
keys
)
{
// Output key-value pairs
console
.
log
(
key
);
console
.
log
(
key
);
}
}
```
```
...
@@ -849,9 +858,10 @@ values(): IterableIterator<string>
...
@@ -849,9 +858,10 @@ values(): IterableIterator<string>
**示例:**
**示例:**
```
j
s
```
t
s
let
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
())
{
let
values
=
Array
.
from
(
searchParams
.
values
());
for
(
let
value
of
values
)
{
console
.
log
(
value
);
console
.
log
(
value
);
}
}
```
```
...
@@ -877,10 +887,12 @@ for (var value of searchParams.values()) {
...
@@ -877,10 +887,12 @@ for (var value of searchParams.values()) {
**示例:**
**示例:**
```
j
s
```
t
s
const
paramsObject
=
new
Url
.
URLSearchParams
(
'
fod=bay&edg=bap
'
);
const
paramsObject
=
new
Url
.
URLSearchParams
(
'
fod=bay&edg=bap
'
);
for
(
const
[
name
,
value
]
of
paramsObject
)
{
let
iter
:
Iterable
<
Object
[]
>
=
paramsObject
[
Symbol
.
iterator
]();
console
.
log
(
name
,
value
);
let
pairs
=
Array
.
from
(
iter
);
for
(
let
pair
of
pairs
)
{
console
.
log
(
pair
[
0
]
+
'
,
'
+
pair
[
1
]);
}
}
```
```
...
@@ -904,7 +916,7 @@ toString(): string
...
@@ -904,7 +916,7 @@ toString(): string
**示例:**
**示例:**
```
j
s
```
t
s
let
url
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
url
=
new
Url
.
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
params
=
new
Url
.
URLSearchParams
(
url
.
search
.
slice
(
1
));
let
params
=
new
Url
.
URLSearchParams
(
url
.
search
.
slice
(
1
));
params
.
append
(
'
fod
'
,
'
3
'
);
params
.
append
(
'
fod
'
,
'
3
'
);
...
...
zh-cn/application-dev/reference/apis/js-apis-xml.md
浏览文件 @
ce33b186
此差异已折叠。
点击以展开。
Miykael_xxm
🚴
@xiongjiamu
mentioned in commit
16ddbed8
·
9月 07, 2023
mentioned in commit
16ddbed8
mentioned in commit 16ddbed8a6603446d5fe1f742dacde8aff6f4632
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录