Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
b23b1908
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,发现更多精彩内容 >>
未验证
提交
b23b1908
编写于
6月 23, 2022
作者:
O
openharmony_ci
提交者:
Gitee
6月 23, 2022
浏览文件
操作
浏览文件
下载
差异文件
!5768 语言基础类库示例代码修改
Merge pull request !5768 from zengyawen/OpenHarmony-3.2-Beta1
上级
953b0d27
4426b45c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
48 addition
and
40 deletion
+48
-40
zh-cn/application-dev/reference/apis/js-apis-url.md
zh-cn/application-dev/reference/apis/js-apis-url.md
+37
-37
zh-cn/application-dev/reference/apis/js-apis-util.md
zh-cn/application-dev/reference/apis/js-apis-util.md
+3
-3
zh-cn/application-dev/reference/apis/js-apis-xml.md
zh-cn/application-dev/reference/apis/js-apis-xml.md
+8
-0
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-url.md
浏览文件 @
b23b1908
...
...
@@ -30,11 +30,11 @@ URLSearchParams的构造函数。
**示例:**
```
js
var
objectParams
=
new
URLSearchParams
([
[
'
user1
'
,
'
abc1
'
],
[
'
query2
'
,
'
first2
'
],
[
'
query3
'
,
'
second3
'
]
]);
var
objectParams1
=
new
URLSearchParams
({
"
fod
"
:
1
,
"
bard
"
:
2
});
var
objectParams2
=
new
URLSearchParams
(
'
?fod=1&bard=2
'
);
var
urlObject
=
new
URL
(
'
https://developer.mozilla.org/?fod=1&bard=2
'
);
var
params
=
new
URLSearchParams
(
urlObject
.
search
);
var
objectParams
=
new
U
rl
.
U
RLSearchParams
([
[
'
user1
'
,
'
abc1
'
],
[
'
query2
'
,
'
first2
'
],
[
'
query3
'
,
'
second3
'
]
]);
var
objectParams1
=
new
U
rl
.
U
RLSearchParams
({
"
fod
"
:
1
,
"
bard
"
:
2
});
var
objectParams2
=
new
U
rl
.
U
RLSearchParams
(
'
?fod=1&bard=2
'
);
var
urlObject
=
new
U
rl
.
U
RL
(
'
https://developer.mozilla.org/?fod=1&bard=2
'
);
var
params
=
new
U
rl
.
U
RLSearchParams
(
urlObject
.
search
);
```
...
...
@@ -56,8 +56,8 @@ append(name: string, value: string): void
**示例:**
```
js
let
urlObject
=
new
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsObject
=
new
URLSearchParams
(
urlObject
.
search
.
slice
(
1
));
let
urlObject
=
new
U
rl
.
U
RL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsObject
=
new
U
rl
.
U
RLSearchParams
(
urlObject
.
search
.
slice
(
1
));
paramsObject
.
append
(
'
fod
'
,
3
);
```
...
...
@@ -79,8 +79,8 @@ delete(name: string): void
**示例:**
```
js
let
urlObject
=
new
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsobject
=
new
URLSearchParams
(
urlObject
.
search
.
slice
(
1
));
let
urlObject
=
new
U
rl
.
U
RL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsobject
=
new
U
rl
.
U
RLSearchParams
(
urlObject
.
search
.
slice
(
1
));
paramsobject
.
delete
(
'
fod
'
);
```
...
...
@@ -108,8 +108,8 @@ getAll(name: string): string[]
**示例:**
```
js
let
urlObject
=
new
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsObject
=
new
URLSearchParams
(
urlObject
.
search
.
slice
(
1
));
let
urlObject
=
new
U
rl
.
U
RL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsObject
=
new
U
rl
.
U
RLSearchParams
(
urlObject
.
search
.
slice
(
1
));
paramsObject
.
append
(
'
fod
'
,
3
);
// Add a second value for the fod parameter.
console
.
log
(
params
.
getAll
(
'
fod
'
))
// Output ["1","3"].
```
...
...
@@ -132,7 +132,7 @@ entries(): IterableIterator<[string, string]>
**示例:**
```
js
var
searchParamsObject
=
new
URLSearchParams
(
"
keyName1=valueName1&keyName2=valueName2
"
);
var
searchParamsObject
=
new
U
rl
.
U
RLSearchParams
(
"
keyName1=valueName1&keyName2=valueName2
"
);
for
(
var
pair
of
searchParamsObject
.
entries
())
{
// Show keyName/valueName pairs
console
.
log
(
pair
[
0
]
+
'
,
'
+
pair
[
1
]);
}
...
...
@@ -165,7 +165,7 @@ forEach(callbackfn: (value: string, key: string, searchParams: this) => void, th
**示例:**
```
js
const
myURLObject
=
new
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
const
myURLObject
=
new
U
rl
.
U
RL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
myURLObject
.
searchParams
.
forEach
((
value
,
name
,
searchParams
)
=>
{
console
.
log
(
name
,
value
,
myURLObject
.
searchParams
===
searchParams
);
});
...
...
@@ -196,7 +196,7 @@ get(name: string): string | null
**示例:**
```
js
var
paramsOject
=
new
URLSearchParams
(
document
.
location
.
search
.
substring
(
1
));
var
paramsOject
=
new
U
rl
.
U
RLSearchParams
(
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
...
...
@@ -226,8 +226,8 @@ has(name: string): boolean
**示例:**
```
js
let
urlObject
=
new
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsObject
=
new
URLSearchParams
(
urlObject
.
search
.
slice
(
1
));
let
urlObject
=
new
U
rl
.
U
RL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsObject
=
new
U
rl
.
U
RLSearchParams
(
urlObject
.
search
.
slice
(
1
));
paramsObject
.
has
(
'
bard
'
)
===
true
;
```
...
...
@@ -250,8 +250,8 @@ set(name: string, value: string): void
**示例:**
```
js
let
urlObject
=
new
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsObject
=
new
URLSearchParams
(
urlObject
.
search
.
slice
(
1
));
let
urlObject
=
new
U
rl
.
U
RL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
paramsObject
=
new
U
rl
.
U
RLSearchParams
(
urlObject
.
search
.
slice
(
1
));
paramsObject
.
set
(
'
baz
'
,
3
);
// Add a third parameter.
```
...
...
@@ -267,7 +267,7 @@ sort(): void
**示例:**
```
js
var
searchParamsObject
=
new
URLSearchParams
(
"
c=3&a=9&b=4&d=2
"
);
// Create a test URLSearchParams object
var
searchParamsObject
=
new
U
rl
.
U
RLSearchParams
(
"
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
```
...
...
@@ -290,7 +290,7 @@ keys(): IterableIterator<string>
**示例:**
```
js
var
searchParamsObject
=
new
URLSearchParams
(
"
key1=value1&key2=value2
"
);
// Create a URLSearchParamsObject object for testing
var
searchParamsObject
=
new
U
rl
.
U
RLSearchParams
(
"
key1=value1&key2=value2
"
);
// Create a URLSearchParamsObject object for testing
for
(
var
key
of
searchParamsObject
.
keys
())
{
// Output key-value pairs
console
.
log
(
key
);
}
...
...
@@ -314,7 +314,7 @@ values(): IterableIterator<string>
**示例:**
```
js
var
searchParams
=
new
URLSearchParams
(
"
key1=value1&key2=value2
"
);
// Create a URLSearchParamsObject object for testing
var
searchParams
=
new
U
rl
.
U
RLSearchParams
(
"
key1=value1&key2=value2
"
);
// Create a URLSearchParamsObject object for testing
for
(
var
value
of
searchParams
.
values
())
{
console
.
log
(
value
);
}
...
...
@@ -338,7 +338,7 @@ for (var value of searchParams.values()) {
**示例:**
```
js
const
paramsObject
=
new
URLSearchParams
(
'
fod=bay&edg=bap
'
);
const
paramsObject
=
new
U
rl
.
U
RLSearchParams
(
'
fod=bay&edg=bap
'
);
for
(
const
[
name
,
value
]
of
paramsObject
)
{
console
.
log
(
name
,
value
);
}
...
...
@@ -362,8 +362,8 @@ toString(): string
**示例:**
```
js
let
url
=
new
URL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
params
=
new
URLSearchParams
(
url
.
search
.
slice
(
1
));
let
url
=
new
U
rl
.
U
RL
(
'
https://developer.exampleUrl/?fod=1&bard=2
'
);
let
params
=
new
U
rl
.
U
RLSearchParams
(
url
.
search
.
slice
(
1
));
params
.
append
(
'
fod
'
,
3
);
console
.
log
(
params
.
toString
());
```
...
...
@@ -410,17 +410,17 @@ URL的构造函数。
```
js
var
mm
=
'
http://username:password@host:8080
'
;
var
a
=
new
URL
(
"
/
"
,
mm
);
// Output 'http://username:password@host:8080/';
var
b
=
new
URL
(
mm
);
// Output 'http://username:password@host:8080/';
new
URL
(
'
path/path1
'
,
b
);
// Output 'http://username:password@host:8080/path/path1';
var
c
=
new
URL
(
'
/path/path1
'
,
b
);
// Output 'http://username:password@host:8080/path/path1';
new
URL
(
'
/path/path1
'
,
c
);
// Output 'http://username:password@host:8080/path/path1';
new
URL
(
'
/path/path1
'
,
a
);
// Output 'http://username:password@host:8080/path/path1';
new
URL
(
'
/path/path1
'
,
"
https://www.exampleUrl/fr-FR/toto
"
);
// Output https://www.exampleUrl/path/path1
new
URL
(
'
/path/path1
'
,
''
);
// Raises a TypeError exception as '' is not a valid URL
new
URL
(
'
/path/path1
'
);
// Raises a TypeError exception as '/path/path1' is not a valid URL
new
URL
(
'
http://www.shanxi.com
'
,
);
// Output http://www.shanxi.com/
new
URL
(
'
http://www.shanxi.com
'
,
b
);
// Output http://www.shanxi.com/
var
a
=
new
U
rl
.
U
RL
(
"
/
"
,
mm
);
// Output 'http://username:password@host:8080/';
var
b
=
new
U
rl
.
U
RL
(
mm
);
// Output 'http://username:password@host:8080/';
new
U
rl
.
U
RL
(
'
path/path1
'
,
b
);
// Output 'http://username:password@host:8080/path/path1';
var
c
=
new
U
rl
.
U
RL
(
'
/path/path1
'
,
b
);
// Output 'http://username:password@host:8080/path/path1';
new
U
rl
.
U
RL
(
'
/path/path1
'
,
c
);
// Output 'http://username:password@host:8080/path/path1';
new
U
rl
.
U
RL
(
'
/path/path1
'
,
a
);
// Output 'http://username:password@host:8080/path/path1';
new
U
rl
.
U
RL
(
'
/path/path1
'
,
"
https://www.exampleUrl/fr-FR/toto
"
);
// Output https://www.exampleUrl/path/path1
new
U
rl
.
U
RL
(
'
/path/path1
'
,
''
);
// Raises a TypeError exception as '' is not a valid URL
new
U
rl
.
U
RL
(
'
/path/path1
'
);
// Raises a TypeError exception as '/path/path1' is not a valid URL
new
U
rl
.
U
RL
(
'
http://www.shanxi.com
'
,
);
// Output http://www.shanxi.com/
new
U
rl
.
U
RL
(
'
http://www.shanxi.com
'
,
b
);
// Output http://www.shanxi.com/
```
...
...
@@ -441,7 +441,7 @@ toString(): string
**示例:**
```
js
const
url
=
new
URL
(
'
http://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
const
url
=
new
U
rl
.
U
RL
(
'
http://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
url
.
toString
()
```
...
...
@@ -462,6 +462,6 @@ toJSON(): string
**示例:**
```
js
const
url
=
new
URL
(
'
http://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
const
url
=
new
U
rl
.
U
RL
(
'
http://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
url
.
toJSON
()
```
zh-cn/application-dev/reference/apis/js-apis-util.md
浏览文件 @
b23b1908
...
...
@@ -208,9 +208,6 @@ decode(input: Uint8Array, options?: { stream?: false }): string
result
[
4
]
=
0x62
;
result
[
5
]
=
0x63
;
console
.
log
(
"
input num:
"
);
for
(
var
j
=
0
;
j
<
6
;
j
++
)
{
console
.
log
(
result
[
j
]);
}
var
retStr
=
textDecoder
.
decode
(
result
,
{
stream
:
false
});
console
.
log
(
"
retStr =
"
+
retStr
);
```
...
...
@@ -262,6 +259,7 @@ encode(input?: string): Uint8Array
**示例:**
```
js
var
textEncoder
=
new
util
.
TextEncoder
();
var
buffer
=
new
ArrayBuffer
(
20
);
var
result
=
new
Uint8Array
(
buffer
);
result
=
textEncoder
.
encode
(
"
\
uD800¥¥
"
);
```
...
...
@@ -1091,6 +1089,8 @@ type ScopeType = ScopeComparable | number;
```
js
class
Temperature
{
constructor
(
value
){
// 当使用ts语言开发时,需要补充以下代码:
// private readonly _temp: Temperature;
this
.
_temp
=
value
;
}
comapreTo
(
value
){
...
...
zh-cn/application-dev/reference/apis/js-apis-xml.md
浏览文件 @
b23b1908
...
...
@@ -55,6 +55,8 @@ setAttributes(name: string, value: string): void
**示例:**
```
js
var
arrayBuffer
=
new
ArrayBuffer
(
1024
);
var
bufView
=
new
DataView
(
arrayBuffer
);
var
thatSer
=
new
xml
.
XmlSerializer
(
bufView
);
thatSer
.
setAttributes
(
"
importance
"
,
"
high
"
);
```
...
...
@@ -77,6 +79,8 @@ addEmptyElement(name: string): void
**示例:**
```
js
var
arrayBuffer
=
new
ArrayBuffer
(
1024
);
var
bufView
=
new
DataView
(
arrayBuffer
);
var
thatSer
=
new
xml
.
XmlSerializer
(
bufView
);
thatSer
.
addEmptyElement
(
"
b
"
);
// => <b/>
```
...
...
@@ -93,6 +97,8 @@ setDeclaration(): void
**示例:**
```
js
var
arrayBuffer
=
new
ArrayBuffer
(
1024
);
var
bufView
=
new
DataView
(
arrayBuffer
);
var
thatSer
=
new
xml
.
XmlSerializer
(
bufView
);
thatSer
.
setDeclaration
()
// => <?xml version="1.0" encoding="utf-8"?>;
```
...
...
@@ -133,6 +139,8 @@ endElement(): void
**示例:**
```
js
var
arrayBuffer
=
new
ArrayBuffer
(
1024
);
var
bufView
=
new
DataView
(
arrayBuffer
);
var
thatSer
=
new
xml
.
XmlSerializer
(
bufView
);
thatSer
.
setNamespace
(
"
h
"
,
"
http://www.w3.org/TR/html4/
"
);
thatSer
.
startElement
(
"
table
"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录