Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
d7f3bb1e
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看板
未验证
提交
d7f3bb1e
编写于
7月 25, 2022
作者:
O
openharmony_ci
提交者:
Gitee
7月 25, 2022
浏览文件
操作
浏览文件
下载
差异文件
!7076 Modify IDE error
Merge pull request !7076 from 周飞/master
上级
70a82847
828ba300
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
67 addition
and
40 deletion
+67
-40
en/application-dev/reference/apis/js-apis-process.md
en/application-dev/reference/apis/js-apis-process.md
+4
-4
en/application-dev/reference/apis/js-apis-uri.md
en/application-dev/reference/apis/js-apis-uri.md
+2
-2
en/application-dev/reference/apis/js-apis-url.md
en/application-dev/reference/apis/js-apis-url.md
+5
-6
en/application-dev/reference/apis/js-apis-util.md
en/application-dev/reference/apis/js-apis-util.md
+53
-25
en/application-dev/reference/apis/js-apis-xml.md
en/application-dev/reference/apis/js-apis-xml.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-process.md
zh-cn/application-dev/reference/apis/js-apis-process.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-util.md
zh-cn/application-dev/reference/apis/js-apis-util.md
+1
-1
未找到文件。
en/application-dev/reference/apis/js-apis-process.md
浏览文件 @
d7f3bb1e
...
...
@@ -92,7 +92,7 @@ This is a system API and cannot be called by third-party applications.
```
js
var
child
=
process
.
runCmd
(
'
ls
'
);
var
result
=
child
.
wait
();
child
.
getOutput
.
then
(
val
=>
{
child
.
getOutput
()
.
then
(
val
=>
{
console
.
log
(
"
child.getOutput =
"
+
val
);
})
```
...
...
@@ -119,7 +119,7 @@ This is a system API and cannot be called by third-party applications.
```
js
var
child
=
process
.
runCmd
(
'
madir test.text
'
);
var
result
=
child
.
wait
();
child
.
getErrorOutput
.
then
(
val
=>
{
child
.
getErrorOutput
()
.
then
(
val
=>
{
console
.
log
(
"
child.getErrorOutput=
"
+
val
);
})
```
...
...
@@ -286,7 +286,7 @@ Obtains the thread priority based on the specified TID.
**Example**
```
js
var
tid
=
process
.
getTid
()
;
var
tid
=
process
.
tid
;
var
pres
=
process
.
getThreadPriority
(
tid
);
```
...
...
@@ -617,5 +617,5 @@ Sends a signal to the specified process to terminate it.
```
js
var
pres
=
process
.
pid
var
result
=
that
.
kill
(
28
,
pres
)
var
result
=
process
.
kill
(
28
,
pres
)
```
en/application-dev/reference/apis/js-apis-uri.md
浏览文件 @
d7f3bb1e
...
...
@@ -72,8 +72,8 @@ Obtains the query string applicable to this URI.
**Example**
```
js
const
uri
=
new
uri
.
URI
(
'
http://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
uri
.
toString
()
const
result
=
new
uri
.
URI
(
'
http://username:password@host:8080/directory/file?query=pppppp#qwer=da
'
);
result
.
toString
()
```
...
...
en/application-dev/reference/apis/js-apis-url.md
浏览文件 @
d7f3bb1e
...
...
@@ -31,7 +31,7 @@ Creates a **URLSearchParams** instance.
```
js
var
objectParams
=
new
Url
.
URLSearchParams
([
[
'
user1
'
,
'
abc1
'
],
[
'
query2
'
,
'
first2
'
],
[
'
query3
'
,
'
second3
'
]
]);
var
objectParams1
=
new
Url
.
URLSearchParams
({
"
fod
"
:
1
,
"
bard
"
:
2
});
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
);
...
...
@@ -58,7 +58,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
'
);
```
...
...
@@ -196,10 +196,9 @@ Obtains the value of the first key-value pair based on the specified key.
**Example**
```
js
var
paramsOject
=
new
Url
.
URLSearchParams
(
document
.
location
.
search
.
substring
(
1
)
);
var
paramsOject
=
new
Url
.
URLSearchParams
(
'
name=Jonathan&age=18
'
);
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
```
...
...
@@ -252,7 +251,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.
```
...
...
@@ -364,7 +363,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
());
```
...
...
en/application-dev/reference/apis/js-apis-util.md
浏览文件 @
d7f3bb1e
...
...
@@ -91,18 +91,22 @@ Calls back an asynchronous function. In the callback, the first parameter indica
async
function
promiseFn
()
{
return
Promise
.
reject
(
'
value
'
);
}
var
err
=
"
type err
"
;
var
cb
=
util
.
callbackWrapper
(
promiseFn
);
cb
((
err
,
ret
)
=>
{
console
.
log
(
err
);
console
.
log
(
ret
);
})
}
,
err
)
```
## util.promiseWrapper
## util.promiseWrapper
<sup>(deprecated)</sup>
promiseWrapper(original: (err: Object, value: Object) =
>
void): Object
> **Introduce**<br/>
> Starting from API version 9, it is recommended to use [util.promisewrapper9 +] (\utilpromisewrapper9) instead.
Processes an asynchronous function and returns a promise version.
**System capability**
: SystemCapability.Utils.Lang
...
...
@@ -117,6 +121,35 @@ Processes an asynchronous function and returns a promise version.
| -------- | -------- |
| Function | Function in the error-first style (that is,
**(err, value) =>...**
is called as the last parameter) and the promise version.|
**Example**
```
js
function
aysnFun
()
{
return
0
;
}
let
newPromiseObj
=
util
.
promiseWrapper
(
aysnFun
);
newPromiseObj
().
then
(
res
=>
{
console
.
log
(
res
);
})
```
## util.promiseWrapper<sup>9+</sup>
promiseWrapper(original: (err: Object, value: Object) =
>
void): Function
Processes an asynchronous function and returns a promise function.
**System capability**
: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| original | Function | Yes| Asynchronous function.|
**Return value**
| Type| Description|
| -------- | -------- |
| Function | Function in the error-first style (that is,
**(err, value) =>...**
is called as the last parameter) and the promise version.|
**Example**
```
js
function
aysnFun
(
str1
,
str2
)
{
...
...
@@ -287,10 +320,11 @@ Stores the UTF-8 encoded text.
**Example**
```
js
var
that
=
new
util
.
TextEncoder
();
var
buffer
=
new
ArrayBuffer
(
4
);
this
.
dest
=
new
Uint8Array
(
buffer
);
var
result
=
that
.
encodeInto
(
"
abcd
"
,
this
.
dest
);
var
that
=
new
util
.
TextEncoder
()
var
buffer
=
new
ArrayBuffer
(
4
)
var
dest
=
new
Uint8Array
(
buffer
)
var
result
=
new
Object
()
result
=
that
.
encodeInto
(
'
abcd
'
,
dest
)
```
## RationalNumber<sup>8+</sup>
...
...
@@ -337,7 +371,7 @@ Creates a **RationalNumber** object based on the given string.
**Example**
```
js
var
rationalNumber
=
new
util
.
RationalNumber
(
1
,
2
);
var
rational
=
rationalNumer
.
creat
RationalFromString
(
"
3/4
"
);
var
rational
=
util
.
RationalNumber
.
create
RationalFromString
(
"
3/4
"
);
```
...
...
@@ -362,7 +396,7 @@ Compares this **RationalNumber** object with a given object.
**Example**
```
js
var
rationalNumber
=
new
util
.
RationalNumber
(
1
,
2
);
var
rational
=
rationalNumer
.
creat
RationalFromString
(
"
3/4
"
);
var
rational
=
util
.
RationalNumber
.
create
RationalFromString
(
"
3/4
"
);
var
result
=
rationalNumber
.
compareTo
(
rational
);
```
...
...
@@ -408,7 +442,7 @@ Checks whether this **RationalNumber** object equals the given object.
**Example**
```
js
var
rationalNumber
=
new
util
.
RationalNumber
(
1
,
2
);
var
rational
=
rationalNumer
.
creat
RationalFromString
(
"
3/4
"
);
var
rational
=
util
.
RationalNumber
.
create
RationalFromString
(
"
3/4
"
);
var
result
=
rationalNumber
.
equals
(
rational
);
```
...
...
@@ -435,7 +469,7 @@ Obtains the greatest common divisor of two specified integers.
**Example**
```
js
var
rationalNumber
=
new
util
.
RationalNumber
(
1
,
2
);
var
result
=
r
ationalNumber
.
getCommonDivisor
(
4
,
6
);
var
result
=
util
.
R
ationalNumber
.
getCommonDivisor
(
4
,
6
);
```
...
...
@@ -672,7 +706,7 @@ Clears key-value pairs from this buffer. The **afterRemoval()** method will be c
```
js
var
pro
=
new
util
.
LruBuffer
();
pro
.
put
(
2
,
10
);
var
result
=
pro
.
size
()
;
var
result
=
pro
.
length
;
pro
.
clear
();
```
...
...
@@ -948,20 +982,13 @@ Performs subsequent operations after a value is removed.
**Example**
```
js
var
arr
=
[];
var
arr
=
[];
class
ChildLruBuffer
extends
util
.
LruBuffer
{
constructor
()
{
super
();
}
static
getInstance
()
{
if
(
this
.
instance
==
null
)
{
this
.
instance
=
new
ChildLruBuffer
();
}
return
this
.
instance
;
}
afterRemoval
(
isEvict
,
key
,
value
,
newValue
)
{
if
(
isEvict
===
false
)
...
...
@@ -970,7 +997,8 @@ Performs subsequent operations after a value is removed.
}
}
}
ChildLruBuffer
.
getInstance
().
afterRemoval
(
false
,
10
,
30
,
null
);
var
lru
=
new
ChildLruBuffer
();
lru
.
afterRemoval
(
false
,
10
,
30
,
null
);
```
...
...
@@ -1063,7 +1091,7 @@ Obtains a two-dimensional array in key-value pairs.
```
js
var
pro
=
new
util
.
LruBuffer
();
pro
.
put
(
2
,
10
);
var
result
=
pro
[
s
ymbol
.
iterator
]();
var
result
=
pro
[
S
ymbol
.
iterator
]();
```
...
...
@@ -1551,7 +1579,7 @@ Encodes the input content asynchronously.
var
rarray
=
new
Uint8Array
([
99
,
122
,
69
,
122
]);
that
.
encode
(
array
).
then
(
val
=>
{
for
(
var
i
=
0
;
i
<
rarray
.
length
;
i
++
)
{
console
.
log
(
val
[
i
])
console
.
log
(
val
[
i
]
.
toString
()
)
}
})
```
...
...
@@ -1610,7 +1638,7 @@ Decodes the input content asynchronously.
var
rarray
=
new
Uint8Array
([
115
,
49
,
51
]);
that
.
decode
(
array
).
then
(
val
=>
{
for
(
var
i
=
0
;
i
<
rarray
.
length
;
i
++
)
{
console
.
log
(
val
[
i
])
console
.
log
(
val
[
i
]
.
toString
()
)
}
})
```
...
...
@@ -1654,7 +1682,7 @@ Checks whether the input value is of the **ArrayBuffer** type.
**Example**
```
js
var
that
=
new
util
.
types
();
var
result
=
that
.
isAnyArrayBuffer
(
new
ArrayBuffer
(
[]
));
var
result
=
that
.
isAnyArrayBuffer
(
new
ArrayBuffer
(
0
));
```
...
...
@@ -1734,7 +1762,7 @@ Checks whether the input value is of the **ArrayBuffer** type.
**Example**
```
js
var
that
=
new
util
.
types
();
var
result
=
that
.
isArrayBuffer
(
new
ArrayBuffer
(
[]
));
var
result
=
that
.
isArrayBuffer
(
new
ArrayBuffer
(
0
));
```
...
...
en/application-dev/reference/apis/js-apis-xml.md
浏览文件 @
d7f3bb1e
...
...
@@ -146,7 +146,7 @@ thatSer.setNamespace("h", "http://www.w3.org/TR/html4/");
thatSer
.
startElement
(
"
table
"
);
thatSer
.
setAttributes
(
"
importance
"
,
"
high
"
);
thatSer
.
setText
(
"
Happy
"
);
endElement
();
// => <h:table importance="high" xmlns:h="http://www.w3.org/TR/html4/">Happy</h:table>
thatSer
.
endElement
();
// => <h:table importance="high" xmlns:h="http://www.w3.org/TR/html4/">Happy</h:table>
```
...
...
zh-cn/application-dev/reference/apis/js-apis-process.md
浏览文件 @
d7f3bb1e
...
...
@@ -232,7 +232,7 @@ is64Bit(): boolean
**示例:**
```
js
var
res
s
ult
=
process
.
is64Bit
();
var
result
=
process
.
is64Bit
();
```
...
...
zh-cn/application-dev/reference/apis/js-apis-util.md
浏览文件 @
d7f3bb1e
...
...
@@ -60,7 +60,7 @@ getErrorString(errno: number): string
**示例:**
```
js
var
errnum
=
10
;
// 10
:
a system error number
var
errnum
=
10
;
// 10
:
a system error number
var
result
=
util
.
getErrorString
(
errnum
);
console
.
log
(
"
result =
"
+
result
);
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录