Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
43293341
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,发现更多精彩内容 >>
未验证
提交
43293341
编写于
4月 26, 2022
作者:
O
openharmony_ci
提交者:
Gitee
4月 26, 2022
浏览文件
操作
浏览文件
下载
差异文件
!3482 misc增加示例代码语言类型
Merge pull request !3482 from lovechinamo/master
上级
aefd1382
decd70ee
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
291 addition
and
291 deletion
+291
-291
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
+8
-8
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
...plication-dev/reference/apis/js-apis-inputmethodengine.md
+30
-30
zh-cn/application-dev/reference/apis/js-apis-pasteboard.md
zh-cn/application-dev/reference/apis/js-apis-pasteboard.md
+39
-39
zh-cn/application-dev/reference/apis/js-apis-request.md
zh-cn/application-dev/reference/apis/js-apis-request.md
+54
-54
zh-cn/application-dev/reference/apis/js-apis-system-time.md
zh-cn/application-dev/reference/apis/js-apis-system-time.md
+83
-83
zh-cn/application-dev/reference/apis/js-apis-wallpaper.md
zh-cn/application-dev/reference/apis/js-apis-wallpaper.md
+77
-77
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
浏览文件 @
43293341
...
...
@@ -47,7 +47,7 @@ getInputMethodController(): InputMethodController
| [InputMethodController](#InputMethodController) | 回调返回当前客户端实例。 |
-
示例
```
```
js
var
InputMethodController
=
inputMethod
.
getInputMethodController
();
```
## inputMethod.getInputMethodSetting<sup>8+</sup><a name="getInputMethodSetting"></a>
...
...
@@ -66,7 +66,7 @@ getInputMethodSetting(): InputMethodSetting
-
示例
```
```
js
var
InputMethodSetting
=
inputMethod
.
getInputMethodSetting
();
```
...
...
@@ -90,7 +90,7 @@ stopInput(callback: AsyncCallback<boolean>): void
-
示例
```
```
js
InputMethodController
.
stopInput
((
error
)
=>
{
console
.
info
(
'
stopInput
'
);
});
...
...
@@ -113,7 +113,7 @@ stopInput(): Promise<boolean>
-
示例
```
```
js
var
isSuccess
=
InputMethodController
.
stopInput
();
console
.
info
(
'
stopInput isSuccess =
'
+
isSuccess
);
```
...
...
@@ -136,7 +136,7 @@ listInputMethod(callback: AsyncCallback<Array<InputMethodProperty>>)
| callback | Array
<
[
InputMethodProperty
](
#InputMethodProperty
)
>
| 是 | 返回已安装输入法列表。 |
-
示例
```
```
js
InputMethodSetting
.
listInputMethod
((
properties
)
=>
{
for
(
var
i
=
0
;
i
<
properties
.
length
;
i
++
)
{
var
property
=
properties
[
i
];
...
...
@@ -159,7 +159,7 @@ listInputMethod(): Promise<Array<InputMethodProperty>>
| Promise
<Array
<[
InputMethodProperty
](
#InputMethodProperty
)
>
> | 返回已安装输入法列表。 |
-
示例
```
```
js
var
properties
=
InputMethodSetting
.
listInputMethod
();
for
(
var
i
=
0
;
i
<
properties
.
length
;
i
++
)
{
var
property
=
properties
[
i
];
...
...
@@ -182,7 +182,7 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。 |
-
示例
```
```
js
InputMethodSetting
.
displayOptionalInputMethod
(()
=>
{
console
.
info
(
'
displayOptionalInputMethod is called
'
);
});
...
...
@@ -203,6 +203,6 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void
| Promise
<
void
>
| 回调函数。 |
-
示例
```
```
js
InputMethodSetting
.
displayOptionalInputMethod
();
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
浏览文件 @
43293341
...
...
@@ -60,7 +60,7 @@ getInputMethodEngine(): InputMethodEngine
-
示例
```
```
js
var
InputMethodEngine
=
inputMethodEngine
.
getInputMethodEngine
();
```
...
...
@@ -80,7 +80,7 @@ createKeyboardDelegate(): KeyboardDelegate
-
示例
```
```
js
var
KeyboardDelegate
=
inputMethodEngine
.
createKeyboardDelegate
();
```
...
...
@@ -105,7 +105,7 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli
-
示例:
```
```
js
InputMethodEngine
.
on
(
'
inputStart
'
,
(
kbController
,
textInputClient
)
=>
{
KeyboardController
=
kbController
;
TextInputClient
=
textInputClient
;
...
...
@@ -131,7 +131,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputC
-
示例:
```
```
js
InputMethodEngine
.
off
(
'
inputStart
'
);
```
...
...
@@ -152,7 +152,7 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void
-
示例:
```
```
js
InputMethodEngine
.
on
(
'
keyboardShow
'
,
(
err
)
=>
{
console
.
info
(
'
keyboardShow
'
);
});
...
...
@@ -175,7 +175,7 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void
-
示例:
```
```
js
InputMethodEngine
.
off
(
'
keyboardShow
'
);
```
...
...
@@ -203,7 +203,7 @@ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void
-
示例:
```
```
js
KeyboardDelegate
.
on
(
'
keyDown
'
,
(
event
)
=>
{
console
.
info
(
'
keyDown
'
);
});
...
...
@@ -226,7 +226,7 @@ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void
-
示例:
```
```
js
KeyboardDelegate
.
off
(
'
keyDown
'
);
```
...
...
@@ -249,7 +249,7 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) =
-
示例:
```
```
js
KeyboardDelegate
.
on
(
'
cursorContextChange
'
,
(
x
,
y
,
height
)
=>
{
console
.
info
(
'
cursorContextChange
'
);
});
...
...
@@ -273,7 +273,7 @@ off(type: 'cursorContextChange', callback?: (x: number, y:number, height:number)
-
示例:
```
```
js
KeyboardDelegate.off('cursorContextChange');
```
### on('selectionChange')
...
...
@@ -293,7 +293,7 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi
-
示例:
```
```
js
KeyboardDelegate
.
on
(
'
selectionChange
'
,
(
oldBegin
,
oldEnd
,
newBegin
,
newEnd
)
=>
{
console
.
info
(
'
selectionChange
'
);
});
...
...
@@ -316,7 +316,7 @@ off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBe
-
示例:
```
```
js
KeyboardDelegate.off('selectionChange');
```
...
...
@@ -338,7 +338,7 @@ on(type: 'textChange', callback: (text: string) => void): void
-
示例:
```
```
js
KeyboardDelegate.on('textChange', (text) => {
console.info('textChange');
});
...
...
@@ -361,7 +361,7 @@ off(type: 'textChange', callback?: (text: string) => void): void
-
示例:
```
```
js
KeyboardDelegate.off('textChange');
```
...
...
@@ -386,7 +386,7 @@ hideKeyboard(callback: AsyncCallback<void>): void
-
示例
```
```
js
KeyboardController
.
hideKeyboard
(()
=>
{
});
```
...
...
@@ -408,7 +408,7 @@ hideKeyboard(): Promise<void>
-
示例
```
```
js
KeyboardController
.
hideKeyboard
();
```
...
...
@@ -432,7 +432,7 @@ getForward(length:number, callback: AsyncCallback<string>): void
| callback | AsyncCallback
<
string
>
| 是 | 返回文本。 |
-
示例
```
```
js
TextInputClient
.
getForward
(
5
,(
text
)
=>
{
console
.
info
(
"
text =
"
+
text
);
});
...
...
@@ -458,7 +458,7 @@ getForward(length:number): Promise<string>
| Promise
<
string
>
| 返回文本。 |
-
示例
```
```
js
var
text
=
TextInputClient
.
getForward
(
5
);
console
.
info
(
"
text =
"
+
text
);
```
...
...
@@ -479,7 +479,7 @@ getBackward(length:number, callback: AsyncCallback<string>): void
| callback | AsyncCallback
<
string
>
| 是 | 返回文本。 |
-
示例
```
```
js
TextInputClient
.
getBackward
(
5
,(
text
)
=>
{
console
.
info
(
"
text =
"
+
text
);
});
...
...
@@ -505,7 +505,7 @@ getBackward(length:number): Promise<string>
| Promise
<
string
>
| 返回文本。 |
-
示例
```
```
js
var
text
=
TextInputClient
.
getBackward
(
5
);
console
.
info
(
"
text =
"
+
text
);
```
...
...
@@ -526,7 +526,7 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void
| callback | AsyncCallback
<
boolean
>
| 是 | 操作成功与否。 |
-
示例
```
```
js
TextInputClient
.
deleteForward
(
5
,(
isSuccess
)
=>
{
console
.
info
(
"
isSuccess =
"
+
isSuccess
);
});
...
...
@@ -551,7 +551,7 @@ deleteForward(length:number): Promise<boolean>
| Promise
<
boolean
>
| 操作成功与否。 |
-
示例
```
```
js
var
isSuccess
=
TextInputClient
.
deleteForward
(
5
);
console
.
info
(
"
isSuccess =
"
+
isSuccess
);
```
...
...
@@ -572,7 +572,7 @@ deleteBackward(length:number, callback: AsyncCallback<boolean>): void
| callback | AsyncCallback<boolean> | 是 | 操作成功与否。 |
-
示例
```
```
js
TextInputClient
.
deleteBackward
(
5
,
(
isSuccess
)
=>
{
console
.
info
(
"
isSuccess =
"
+
isSuccess
);
});
...
...
@@ -598,7 +598,7 @@ deleteBackward(length:number): Promise<boolean>
-
示例
```
```
js
var isSuccess = TextInputClient.deleteBackward(5);
console.info("isSuccess = " + isSuccess);
```
...
...
@@ -618,7 +618,7 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void
| callback | AsyncCallback<boolean> | 是 | 操作成功与否。 |
-
示例
```
```
js
TextInputClient
.
sendKeyFunction
(
inputMethod
.
ENTER_KEY_TYPE_NEXT
,(
isSuccess
)
=>
{
console
.
info
(
"
isSuccess =
"
+
isSuccess
);
});
...
...
@@ -644,7 +644,7 @@ sendKeyFunction(action:number): Promise<boolean>
-
示例
```
```
js
var
isSuccess
=
TextInputClient
.
sendKeyFunction
(
inputMethod
.
ENTER_KEY_TYPE_NEXT
);
console
.
info
(
"
isSuccess =
"
+
isSuccess
);
```
...
...
@@ -665,7 +665,7 @@ insertText(text:string, callback: AsyncCallback<boolean>): void
| callback | AsyncCallback<boolean> | 是 | 操作成功与否。 |
-
示例
```
```
js
TextInputClient
.
insertText
(
"
test
"
,
(
isSuccess
)
=>
{
console
.
info
(
"
isSuccess =
"
+
isSuccess
);
});
...
...
@@ -691,7 +691,7 @@ insertText(text:string): Promise<boolean>
-
示例
```
```
js
var
isSuccess
=
TextInputClient
.
insertText
(
"
test
"
);
console
.
info
(
"
isSuccess =
"
+
isSuccess
);
```
...
...
@@ -710,7 +710,7 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void
| callback | AsyncCallback
<
[EditorAttribute](#EditorAttribute)
>
| 是 | 编辑框属性值。 |
-
示例
```
```
js
TextInputClient
.
getEditorAttribute
((
EditorAttribute
)
=>
{
});
```
...
...
@@ -729,7 +729,7 @@ getEditorAttribute(): Promise<EditorAttribute>
| Promise
<
[EditorAttribute](#EditorAttribute)
>
| 返回编辑框属性值。 |
-
示例
```
```
js
var
EditorAttribute
=
TextInputClient
.
getEditorAttribute
();
```
...
...
zh-cn/application-dev/reference/apis/js-apis-pasteboard.md
浏览文件 @
43293341
...
...
@@ -46,7 +46,7 @@ createPlainTextData(text:string): PasteData
**示例**
```
```
js
var
pasteData
=
pasteboard
.
createPlainTextData
(
"
content
"
);
```
...
...
@@ -71,7 +71,7 @@ createHtmlData(htmlText:string): PasteData
**示例**
```
```
js
var
html
=
"
<!DOCTYPE html>
\n
"
+
"
<html>
\n
"
+
"
<head>
\n
"
+
"
<meta charset=
\"
utf-8
\"
>
\n
"
+
"
<title>HTML-PASTEBOARD_HTML</title>
\n
"
+
"
</head>
\n
"
+
"
<body>
\n
"
+
"
<h1>HEAD</h1>
\n
"
+
"
<p></p>
\n
"
+
"
</body>
\n
"
+
"
</html>
"
;
var
pasteData
=
pasteboard
.
createHtmlData
(
html
);
```
...
...
@@ -97,7 +97,7 @@ createWantData(want:Want): PasteData
**示例**
```
```
js
var
object
=
{
bundleName
:
"
com.example.aafwk.test
"
,
abilityName
:
"
com.example.aafwk.test.TwoAbility
"
...
...
@@ -126,7 +126,7 @@ createUriData(uri:string): PasteData
**示例**
```
```
js
var
pasteData
=
pasteboard
.
createUriData
(
"
dataability:///com.example.myapplication1?user.txt
"
);
```
...
...
@@ -151,7 +151,7 @@ createPlainTextRecord(text:string): PasteDataRecord
**示例**
```
```
js
var
record
=
pasteboard
.
createPlainTextRecord
(
"
hello
"
);
```
...
...
@@ -176,7 +176,7 @@ createHtmlTextRecord(htmlText:string): PasteDataRecord
**示例**
```
```
js
var
html
=
"
<!DOCTYPE html>
\n
"
+
"
<html>
\n
"
+
"
<head>
\n
"
+
"
<meta charset=
\"
utf-8
\"
>
\n
"
+
"
<title>HTML-PASTEBOARD_HTML</title>
\n
"
+
"
</head>
\n
"
+
"
<body>
\n
"
+
"
<h1>HEAD</h1>
\n
"
+
"
<p></p>
\n
"
+
"
</body>
\n
"
+
"
</html>
"
;
var
record
=
pasteboard
.
createHtmlTextRecord
(
html
);
```
...
...
@@ -202,7 +202,7 @@ createWantRecord(want:Want): PasteDataRecord
**示例**
```
```
js
var
object
=
{
bundleName
:
"
com.example.aafwk.test
"
,
abilityName
:
"
com.example.aafwk.test.TwoAbility
"
...
...
@@ -231,7 +231,7 @@ createUriRecord(uri:string): PasteDataRecord
**示例**
```
```
js
var
record
=
pasteboard
.
createUriRecord
(
"
dataability:///com.example.myapplication1?user.txt
"
);
```
...
...
@@ -284,7 +284,7 @@ convertToText(): Promise<string>
**示例**
```
```
js
var
record
=
pasteboard
.
createUriRecord
(
"
dataability:///com.example.myapplication1?user.txt
"
);
record
.
convertToText
().
then
((
data
)
=>
{
console
.
info
(
'
convertToText success data :
'
+
JSON
.
stringify
(
data
));
...
...
@@ -309,7 +309,7 @@ convertToText(callback: AsyncCallback<string>): void
**示例**
```
```
js
var
record
=
pasteboard
.
createUriRecord
(
"
dataability:///com.example.myapplication1?user.txt
"
);
record
.
convertToText
((
err
,
data
)
=>
{
if
(
err
)
{
...
...
@@ -346,7 +346,7 @@ getPrimaryText(): string
**示例**
```
```
js
var
pasteData
=
pasteboard
.
createPlainTextData
(
"
hello
"
);
var
plainText
=
pasteData
.
getPrimaryText
();
```
...
...
@@ -367,7 +367,7 @@ getPrimaryHtml(): string
**示例**
```
```
js
var
html
=
"
<!DOCTYPE html>
\n
"
+
"
<html>
\n
"
+
"
<head>
\n
"
+
"
<meta charset=
\"
utf-8
\"
>
\n
"
+
"
<title>HTML-PASTEBOARD_HTML</title>
\n
"
+
"
</head>
\n
"
+
"
<body>
\n
"
+
"
<h1>HEAD</h1>
\n
"
+
"
<p></p>
\n
"
+
"
</body>
\n
"
+
"
</html>
"
;
var
pasteData
=
pasteboard
.
createHtmlData
(
html
);
var
htmlText
=
pasteData
.
getPrimaryHtml
();
...
...
@@ -389,7 +389,7 @@ getPrimaryWant(): Want
**示例**
```
```
js
var
object
=
{
bundleName
:
"
com.example.aafwk.test
"
,
abilityName
:
"
com.example.aafwk.test.TwoAbility
"
...
...
@@ -414,7 +414,7 @@ getPrimaryUri(): string
**示例**
```
```
js
var
pasteData
=
pasteboard
.
createUriData
(
"
dataability:///com.example.myapplication1?user.txt
"
);
var
uri
=
pasteData
.
getPrimaryUri
();
```
...
...
@@ -437,7 +437,7 @@ addTextRecord(text: string): void
**示例**
```
```
js
var
pasteData
=
pasteboard
.
createPlainTextData
(
"
hello
"
);
pasteData
.
addTextRecord
(
"
good
"
);
```
...
...
@@ -460,7 +460,7 @@ addHtmlRecord(htmlText: string): void
**示例**
```
```
js
var
pasteData
=
pasteboard
.
createPlainTextData
(
"
hello
"
);
var
html
=
"
<!DOCTYPE html>
\n
"
+
"
<html>
\n
"
+
"
<head>
\n
"
+
"
<meta charset=
\"
utf-8
\"
>
\n
"
+
"
<title>HTML-PASTEBOARD_HTML</title>
\n
"
+
"
</head>
\n
"
+
"
<body>
\n
"
+
"
<h1>HEAD</h1>
\n
"
+
"
<p></p>
\n
"
+
"
</body>
\n
"
+
"
</html>
"
;
pasteData
.
addHtmlRecord
(
html
);
...
...
@@ -484,7 +484,7 @@ addWantRecord(want: Want): void
**示例**
```
```
js
var
pasteData
=
pasteboard
.
createPlainTextData
(
"
hello
"
);
var
object
=
{
bundleName
:
"
com.example.aafwk.test
"
,
...
...
@@ -511,7 +511,7 @@ addUriRecord(uri: string): void
**示例**
```
```
js
var
pasteData
=
pasteboard
.
createPlainTextData
(
"
hello
"
);
pasteData
.
addUriRecord
(
"
dataability:///com.example.myapplication1?user.txt
"
);
```
...
...
@@ -534,7 +534,7 @@ addRecord(record: PasteDataRecord): void
**示例**
```
```
js
var
pasteData
=
pasteboard
.
createUriData
(
"
dataability:///com.example.myapplication1?user.txt
"
);
var
textRecord
=
pasteboard
.
createPlainTextRecord
(
"
hello
"
);
var
html
=
"
<!DOCTYPE html>
\n
"
+
"
<html>
\n
"
+
"
<head>
\n
"
+
"
<meta charset=
\"
utf-8
\"
>
\n
"
+
"
<title>HTML-PASTEBOARD_HTML</title>
\n
"
+
"
</head>
\n
"
+
"
<body>
\n
"
+
"
<h1>HEAD</h1>
\n
"
+
"
<p></p>
\n
"
+
"
</body>
\n
"
+
"
</html>
"
;
...
...
@@ -559,7 +559,7 @@ getMimeTypes(): Array<string>
**示例**
```
```
js
var
pasteData
=
pasteboard
.
createPlainTextData
(
"
hello
"
);
var
types
=
pasteData
.
getMimeTypes
();
```
...
...
@@ -580,7 +580,7 @@ getPrimaryMimeType(): string
**示例**
```
```
js
var
pasteData
=
pasteboard
.
createPlainTextData
(
"
hello
"
);
var
type
=
pasteData
.
getPrimaryMimeType
();
```
...
...
@@ -601,7 +601,7 @@ getProperty(): PasteDataProperty
**示例**
```
```
js
var
pasteData
=
pasteboard
.
createPlainTextData
(
"
hello
"
);
var
property
=
pasteData
.
getProperty
();
```
...
...
@@ -627,7 +627,7 @@ getRecordAt(index: number): PasteDataRecord
**示例**
```
```
js
var
pasteData
=
pasteboard
.
createPlainTextData
(
"
hello
"
);
var
record
=
pasteData
.
getRecordAt
(
0
);
```
...
...
@@ -648,7 +648,7 @@ getRecordCount(): number
**示例**
```
```
js
var
pasteData
=
pasteboard
.
createPlainTextData
(
"
hello
"
);
var
count
=
pasteData
.
getRecordCount
();
```
...
...
@@ -669,7 +669,7 @@ getTag(): string
**示例**
```
```
js
var
pasteData
=
pasteboard
.
createPlainTextData
(
"
hello
"
);
var
tag
=
pasteData
.
getTag
();
```
...
...
@@ -695,7 +695,7 @@ hasMimeType(mimeType: string): boolean
**示例**
```
```
js
var
pasteData
=
pasteboard
.
createPlainTextData
(
"
hello
"
);
var
hasType
=
pasteData
.
hasMimeType
(
pasteboard
.
MIMETYPE_TEXT_PLAIN
);
```
...
...
@@ -721,7 +721,7 @@ removeRecordAt(index: number): boolean
**示例**
```
```
js
var
pasteData
=
pasteboard
.
createPlainTextData
(
"
hello
"
);
var
isRemove
=
pasteData
.
removeRecordAt
(
0
);
```
...
...
@@ -748,7 +748,7 @@ replaceRecordAt(index: number, record: PasteDataRecord): boolean
**示例**
```
```
js
var
pasteData
=
pasteboard
.
createPlainTextData
(
"
hello
"
);
var
record
=
pasteboard
.
createUriRecord
(
"
dataability:///com.example.myapplication1?user.txt
"
);
var
isReplace
=
pasteData
.
replaceRecordAt
(
0
,
record
);
...
...
@@ -770,7 +770,7 @@ getSystemPasteboard(): SystemPasteboard
**示例**
```
```
js
var
systemPasteboard
=
pasteboard
.
getSystemPasteboard
();
```
...
...
@@ -800,7 +800,7 @@ setPasteData(data:PasteData, callback:AsyncCallback<void>): void
**示例**
```
```
js
var
pasteData
=
pasteboard
.
createPlainTextData
(
"
content
"
);
var
systemPasteboard
=
pasteboard
.
getSystemPasteboard
();
systemPasteboard
.
setPasteData
(
pasteData
,
(
error
,
data
)
=>
{
...
...
@@ -833,7 +833,7 @@ setPasteData(data:PasteData): Promise<void>
**示例**
```
```
js
var
pasteData
=
pasteboard
.
createPlainTextData
(
"
content
"
);
var
systemPasteboard
=
pasteboard
.
getSystemPasteboard
();
systemPasteboard
.
setPasteData
(
pasteData
).
then
((
data
)
=>
{
...
...
@@ -859,7 +859,7 @@ getPasteData( callback:AsyncCallback<PasteData>): void
**示例**
```
```
js
var
systemPasteboard
=
pasteboard
.
getSystemPasteboard
();
systemPasteboard
.
getPasteData
((
error
,
pasteData
)
=>
{
if
(
error
)
{
...
...
@@ -886,7 +886,7 @@ getPasteData(): Promise<PasteData>
**示例**
```
```
js
var
systemPasteboard
=
pasteboard
.
getSystemPasteboard
();
systemPasteboard
.
getPasteData
().
then
((
pasteData
)
=>
{
var
text
=
pasteData
.
getPrimaryText
();
...
...
@@ -912,7 +912,7 @@ on(type: 'update', callback: () =>void ): void
**示例**
```
```
js
var
systemPasteboard
=
pasteboard
.
getSystemPasteboard
();
var
listener
=
()
=>
{
console
.
info
(
'
The system pasteboard has changed
'
);
...
...
@@ -937,7 +937,7 @@ off(type: 'update', callback?: () =>void ): void
**示例**
```
```
js
systemPasteboard
.
off
(
'
update
'
,
listener
);
```
...
...
@@ -957,7 +957,7 @@ hasPasteData(callback: AsyncCallback<boolean>): void
**示例**
```
```
js
systemPasteboard
.
hasPasteData
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to hasPasteData because
'
+
JSON
.
stringify
(
err
));
...
...
@@ -983,7 +983,7 @@ hasPasteData(): Promise<boolean>
**示例**
```
```
js
systemPasteboard
.
hasPasteData
().
then
((
data
)
=>
{
console
.
info
(
'
success hasPasteData :
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
...
...
@@ -1007,7 +1007,7 @@ clear(callback: AsyncCallback<void>): void
**示例**
```
```
js
systemPasteboard
.
clear
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to clear because
'
+
JSON
.
stringify
(
err
));
...
...
@@ -1034,7 +1034,7 @@ clear(): Promise<void>
**示例**
```
```
js
systemPasteboard
.
clear
().
then
((
data
)
=>
{
console
.
info
(
'
success clear
'
);
}).
catch
((
error
)
=>
{
...
...
zh-cn/application-dev/reference/apis/js-apis-request.md
浏览文件 @
43293341
...
...
@@ -81,7 +81,7 @@ upload(config: UploadConfig): Promise<UploadTask>
-
示例:
```
```
js
request
.
upload
({
url
:
'
https://patch
'
}).
then
((
data
)
=>
{
uploadTask
=
data
;
}).
catch
((
err
)
=>
{
...
...
@@ -108,7 +108,7 @@ upload(config: UploadConfig, callback: AsyncCallback<UploadTask>): void
-
示例:
```
```
js
request
.
upload
({
url
:
'
https://patch
'
},
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to request the upload. Cause:
'
+
JSON
.
stringify
(
err
));
...
...
@@ -142,14 +142,14 @@ on(type: 'progress', callback:(uploadedSize: number, totalSize: number) => vo
回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| uploadedSize | number | 是 | 当前已上传文件大小,单位为KB。 |
| totalSize | number | 是 | 上传文件的总大小,单位为KB。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| uploadedSize | number | 是 | 当前已上传文件大小,单位为KB。 |
| totalSize | number | 是 | 上传文件的总大小,单位为KB。 |
-
示例:
```
```
js
uploadTask
.
on
(
'
progress
'
,
function
callback
(
uploadedSize
,
totalSize
)
{
console
.
info
(
"
upload totalSize:
"
+
totalSize
+
"
uploadedSize:
"
+
uploadedSize
);
}
...
...
@@ -175,13 +175,13 @@ on(type: 'headerReceive', callback: (header: object) => void): void
回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| header | object | 是 | HTTP
Response
Header。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| header | object | 是 | HTTP
Response
Header。 |
-
示例:
```
```
js
uploadTask
.
on
(
'
headerReceive
'
,
function
callback
(
headers
){
console
.
info
(
"
upOnHeader headers:
"
+
JSON
.
stringify
(
headers
));
}
...
...
@@ -207,14 +207,14 @@ off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) =&g
回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| uploadedSize | number | 是 | 当前已上传文件的大小,单位为KB。 |
| totalSize | number | 是 | 上传文件的总大小,单位为KB。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| uploadedSize | number | 是 | 当前已上传文件的大小,单位为KB。 |
| totalSize | number | 是 | 上传文件的总大小,单位为KB。 |
-
示例:
```
```
js
uploadTask
.
off
(
'
progress
'
,
function
callback
(
uploadedSize
,
totalSize
)
{
console
.
info
(
'
uploadedSize:
'
+
uploadedSize
,
'
totalSize:
'
+
totalSize
);
}
...
...
@@ -240,13 +240,13 @@ off(type: 'headerReceive', callback?: (header: object) => void): void
回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| header | object | 是 | HTTP
Response
Header。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| header | object | 是 | HTTP
Response
Header。 |
-
示例:
```
```
js
uploadTask
.
off
(
'
headerReceive
'
,
function
callback
(
headers
)
{
console
.
info
(
"
upOnHeader headers:
"
+
JSON
.
stringify
(
headers
));
}
...
...
@@ -271,7 +271,7 @@ remove(): Promise<boolean>
-
示例
```
```
js
uploadTask
.
remove
().
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Upload task removed successfully.
'
);
...
...
@@ -301,7 +301,7 @@ remove(callback: AsyncCallback<boolean>): void
-
示例
```
```
js
uploadTask
.
remove
((
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to remove the upload task. Cause:
'
+
JSON
.
stringify
(
err
));
...
...
@@ -373,7 +373,7 @@ download(config: DownloadConfig): Promise<DownloadTask>
-
示例
```
```
js
request
.
download
({
url
:
'
https://xxxx/xxxx.hap
'
}).
then
((
data
)
=>
{
downloadTask
=
data
;
}).
catch
((
err
)
=>
{
...
...
@@ -400,7 +400,7 @@ download(config: DownloadConfig, callback: AsyncCallback<DownloadTask>): v
-
示例
```
```
js
request
.
download
({
url
:
'
https://xxxx/xxxxx.hap
'
,
filePath
:
'
xxx/xxxxx.hap
'
},
(
err
,
data
)
=>
{
if
(
err
)
{
...
...
@@ -435,14 +435,14 @@ on(type: 'progress', callback:(receivedSize: number, totalSize: number) => vo
回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| receivedSize | number | 是 | 当前下载的进度,单位为KB。 |
| totalSize | number | 是 | 下载文件的总大小,单位为KB。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| receivedSize | number | 是 | 当前下载的进度,单位为KB。 |
| totalSize | number | 是 | 下载文件的总大小,单位为KB。 |
-
示例:
```
```
js
request
.
download
({
url
:
'
https://xxxx/xxxx.hap
'
},
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to request download. Cause:
'
+
err
);
...
...
@@ -475,14 +475,14 @@ off(type: 'progress', callback?: (receivedSize: number, totalSize: number) =>
回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| receivedSize | number | 是 | 当前下载的进度。 |
| totalSize | number | 是 | 下载文件的总大小。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| receivedSize | number | 是 | 当前下载的进度。 |
| totalSize | number | 是 | 下载文件的总大小。 |
-
示例:
```
```
js
request
.
download
({
url
:
'
https://xxxx/xxxx.hap
'
},
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to request download. Cause:
'
+
err
);
...
...
@@ -515,7 +515,7 @@ on(type: 'complete'|'pause'|'remove', callback:() => void): void
-
示例:
```
```
js
request
.
download
({
url
:
'
https://xxxx/xxxx.hap
'
},
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to request download. Cause:
'
+
err
);
...
...
@@ -548,7 +548,7 @@ off(type: 'complete'|'pause'|'remove', callback?:() => void): void
-
示例:
```
```
js
request
.
download
({
url
:
'
https://xxxx/xxxx.hap
'
},
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to request download. Cause:
'
+
JSON
.
stringify
(
err
));
...
...
@@ -581,13 +581,13 @@ on(type: 'fail', callback: (err: number) => void): void
回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| err | number | 是 | 下载失败的错误码,错误原因见
[
ERROR.*
](
#常量
)
。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| err | number | 是 | 下载失败的错误码,错误原因见
[
ERROR.*
](
#常量
)
。 |
-
示例
```
```
js
request
.
download
({
url
:
'
https://xxxx/xxxx.hap
'
},
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to request download. Cause:
'
+
err
);
...
...
@@ -620,13 +620,13 @@ off(type: 'fail', callback?: (err: number) => void): void
回调函数的参数
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| err | number | 是 | 下载失败的错误码。错误原因见
[
ERROR_*
](
#常量
)
。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| err | number | 是 | 下载失败的错误码。错误原因见
[
ERROR_*
](
#常量
)
。 |
-
示例
```
```
js
request
.
download
({
url
:
'
https://xxxx/xxxx.hap
'
},
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to request download. Cause:
'
+
err
);
...
...
@@ -658,7 +658,7 @@ remove(): Promise<boolean>
-
示例
```
```
js
downloadTask
.
remove
().
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Download task removed.
'
);
...
...
@@ -688,7 +688,7 @@ remove(callback: AsyncCallback<boolean>): void
-
示例
```
```
js
downloadTask
.
remove
((
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to remove the download task.
'
);
...
...
@@ -720,7 +720,7 @@ query(): Promise<DownloadInfo>
-
示例
```
```
js
downloadTask
.
query
().
then
((
downloadInfo
)
=>
{
console
.
info
(
'
Download task queried. Data:
'
+
JSON
.
stringify
(
downloadInfo
))
})
.
catch
((
err
)
=>
{
...
...
@@ -746,7 +746,7 @@ query(callback: AsyncCallback<DownloadInfo>): void
-
示例:
```
```
js
downloadTask
.
query
((
err
,
downloadInfo
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to query the download mimeType. Cause:
'
+
JSON
.
stringify
(
err
));
...
...
@@ -774,7 +774,7 @@ queryMimeType(): Promise<string>
-
示例
```
```
js
downloadTask
.
queryMimeType
().
then
((
data
)
=>
{
console
.
info
(
'
Download task queried. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
...
...
@@ -800,7 +800,7 @@ queryMimeType(callback: AsyncCallback<string>): void;
-
示例
```
```
js
downloadTask
.
queryMimeType
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to query the download mimeType. Cause:
'
+
JSON
.
stringify
(
err
));
...
...
@@ -828,7 +828,7 @@ pause(): Promise<void>
-
示例
```
```
js
downloadTask
.
pause
().
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Download task paused.
'
);
...
...
@@ -858,7 +858,7 @@ pause(callback: AsyncCallback<void>): void
-
示例
```
```
js
downloadTask
.
pause
((
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to pause the download task. Cause:
'
+
JSON
.
stringify
(
err
));
...
...
@@ -890,7 +890,7 @@ resume(): Promise<void>
-
示例
```
```
js
downloadTask
.
resume
().
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Download task resumed.
'
)
...
...
@@ -921,7 +921,7 @@ resume(callback: AsyncCallback<void>): void
-
示例
```
```
js
downloadTask
.
resume
((
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to resume the download task. Cause:
'
+
err
);
...
...
zh-cn/application-dev/reference/apis/js-apis-system-time.md
浏览文件 @
43293341
...
...
@@ -30,7 +30,7 @@ setTime(time : number, callback : AsyncCallback<void>) : void
-
示例:
```
```
js
// time对应的时间为2021-01-20 02:36:25
var
time
=
1611081385000
;
systemTime
.
setTime
(
time
,
(
error
,
data
)
=>
{
...
...
@@ -65,7 +65,7 @@ setTime(time : number) : Promise<void>
-
示例:
```
```
js
// time对应的时间为2021-01-20 02:36:25
var
time
=
1611081385000
;
systemTime
.
setTime
(
time
).
then
((
data
)
=>
{
...
...
@@ -92,7 +92,7 @@ getCurrentTime(isNano?: boolean, callback: AsyncCallback<number>): void
-
示例:
```
```
js
systemTime
.
getCurrentTime
(
true
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
error
(
`failed to systemTime.getCurrentTime because `
+
JSON
.
stringify
(
error
));
...
...
@@ -123,7 +123,7 @@ getCurrentTime(isNano?: boolean): Promise<number>
-
示例:
```
```
js
systemTime
.
getCurrentTime
().
then
((
data
)
=>
{
console
.
log
(
`systemTime.getCurrentTime success data : `
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
...
...
@@ -148,7 +148,7 @@ getRealActiveTime(isNano?: boolean, callback: AsyncCallback<number>): void
-
示例:
```
```
js
systemTime
.
getRealActiveTime
(
true
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
error
(
`failed to systemTime.getRealActiveTimebecause `
+
JSON
.
stringify
(
error
));
...
...
@@ -179,7 +179,7 @@ getRealActiveTime(isNano?: boolean): Promise<number>
-
示例:
```
```
js
systemTime
.
getCurrentTime
().
then
((
data
)
=>
{
console
.
log
(
`systemTime.getRealActiveTime success data : `
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
...
...
@@ -204,7 +204,7 @@ getRealTime(callback: AsyncCallback<number>): void
-
示例:
```
```
js
systemTime
.
getRealTime
(
true
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
error
(
`failed to systemTime.getRealTime because `
+
JSON
.
stringify
(
error
));
...
...
@@ -235,7 +235,7 @@ getRealTime(): Promise<number>
-
示例:
```
```
js
systemTime
.
getRealTime
().
then
((
data
)
=>
{
console
.
log
(
`systemTime.getRealTime success data: `
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
...
...
@@ -262,7 +262,7 @@ setDate(date: Date, callback: AsyncCallback<void>): void
-
示例:
```
```
js
var
data
=
new
Date
(
"
October 13, 2020 11:13:00
"
);
systemTime
.
setDate
(
data
,(
error
,
data
)
=>
{
if
(
error
)
{
...
...
@@ -296,7 +296,7 @@ setDate(date: Date): Promise<void>
-
示例:
```
```
js
var
data
=
new
Date
(
"
October 13, 2020 11:13:00
"
);
systemTime
.
setDate
(
data
).
then
((
value
)
=>
{
console
.
log
(
`systemTime.setDate success data : `
+
JSON
.
stringify
(
value
));
...
...
@@ -321,7 +321,7 @@ getDate(callback: AsyncCallback<Date>): void
-
示例:
```
```
js
systemTime
.
getDate
((
error
,
data
)
=>
{
if
(
error
)
{
console
.
error
(
`failed to systemTime.getDate because `
+
JSON
.
stringify
(
error
));
...
...
@@ -347,7 +347,7 @@ getDate(): Promise<Date>
-
示例:
```
```
js
systemTime
.
getDate
().
then
((
data
)
=>
{
console
.
log
(
`systemTime.getDate success data : `
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
...
...
@@ -374,7 +374,7 @@ setTimezone(timezone: string, callback: AsyncCallback<void>): void
-
示例:
```
```
js
systemTime
.
setTimezone
(
'
Asia/Shanghai
'
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
error
(
'
failed to systemTime.setTimezone because
'
+
JSON
.
stringify
(
error
));
...
...
@@ -407,7 +407,7 @@ setTimezone(timezone: string): Promise<void>
-
示例:
```
```
js
systemTime
.
setTimezone
(
'
Asia/Shanghai
'
).
then
((
data
)
=>
{
console
.
log
(
`systemTime.setTimezone success data : `
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
...
...
@@ -431,7 +431,7 @@ getTimezone(callback: AsyncCallback<string>): void
-
示例:
```
```
js
systemTime
.
getTimezone
((
error
,
data
)
=>
{
if
(
error
)
{
console
.
error
(
`failed to systemTime.getTimezone because `
+
JSON
.
stringify
(
error
));
...
...
@@ -457,7 +457,7 @@ getTimezone(): Promise<string>
-
示例:
```
```
js
systemTime
.
getTimezone
().
then
((
data
)
=>
{
console
.
log
(
`systemTime.getTimezone success data : `
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
...
...
zh-cn/application-dev/reference/apis/js-apis-wallpaper.md
浏览文件 @
43293341
...
...
@@ -18,7 +18,7 @@ import wallpaper from '@ohos.wallpaper';
**系统能力**
: 以下各项对应的系统能力均为SystemCapability.MiscServices.Wallpaper。
| 名称 | 说明 |
| 名称 | 说明 |
| -------- | -------- |
| WALLPAPER_LOCKSCREEN | 锁屏壁纸标识。 |
| WALLPAPER_SYSTEM | 主屏幕壁纸标识。 |
...
...
@@ -40,7 +40,7 @@ getColors(wallpaperType: WallpaperType, callback: AsyncCallback<Array<Rgba
-
示例:
```
```
js
wallpaper
.
getColors
(
wallpaper
.
WallpaperType
.
WALLPAPER_SYSTEM
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
error
(
`failed to getColors because: `
+
JSON
.
stringify
(
error
));
...
...
@@ -71,7 +71,7 @@ getColors(wallpaperType: WallpaperType): Promise<Array<RgbaColor>>
-
示例:
```
```
js
wallpaper
.
getColors
(
wallpaper
.
WallpaperType
.
WALLPAPER_SYSTEM
).
then
((
data
)
=>
{
console
.
log
(
`success to getColors.`
);
}).
catch
((
error
)
=>
{
...
...
@@ -96,7 +96,7 @@ getId(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void
-
示例:
```
```
js
wallpaper
.
getId
(
wallpaper
.
WallpaperType
.
WALLPAPER_SYSTEM
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
error
(
`failed to getId because: `
+
JSON
.
stringify
(
error
));
...
...
@@ -128,7 +128,7 @@ getId(wallpaperType: WallpaperType): Promise<number>
-
示例:
```
```
js
wallpaper
.
getId
(
wallpaper
.
WallpaperType
.
WALLPAPER_SYSTEM
).
then
((
data
)
=>
{
console
.
log
(
`success to getId: `
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
...
...
@@ -152,7 +152,7 @@ getMinHeight(callback: AsyncCallback<number>): void
-
示例:
```
```
js
wallpaper
.
getMinHeight
((
error
,
data
)
=>
{
if
(
error
)
{
console
.
error
(
`failed to getMinHeight because: `
+
JSON
.
stringify
(
error
));
...
...
@@ -179,7 +179,7 @@ getMinHeight(): Promise<number>
-
示例:
```
```
js
wallpaper
.
getMinHeight
().
then
((
data
)
=>
{
console
.
log
(
`success to getMinHeight: `
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
...
...
@@ -204,7 +204,7 @@ getMinWidth(callback: AsyncCallback<number>): void
-
示例:
```
```
js
wallpaper
.
getMinWidth
((
error
,
data
)
=>
{
if
(
error
)
{
console
.
error
(
`failed to getMinWidth because: `
+
JSON
.
stringify
(
error
));
...
...
@@ -230,7 +230,7 @@ getMinWidth(): Promise<number>
-
示例:
```
```
js
wallpaper
.
getMinWidth
().
then
((
data
)
=>
{
console
.
log
(
`success to getMinWidth: `
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
...
...
@@ -254,7 +254,7 @@ isChangePermitted(callback: AsyncCallback<boolean>): void
-
示例:
```
```
js
wallpaper
.
isChangePermitted
((
error
,
data
)
=>
{
if
(
error
)
{
console
.
error
(
`failed to isChangePermitted because: `
+
JSON
.
stringify
(
error
));
...
...
@@ -280,7 +280,7 @@ isChangePermitted(): Promise<boolean>
-
示例:
```
```
js
wallpaper
.
isChangePermitted
().
then
((
data
)
=>
{
console
.
log
(
`success to isChangePermitted: `
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
...
...
@@ -304,7 +304,7 @@ isOperationAllowed(callback: AsyncCallback<boolean>): void
-
示例:
```
```
js
wallpaper
.
isOperationAllowed
((
error
,
data
)
=>
{
if
(
error
)
{
console
.
error
(
`failed to isOperationAllowed because: `
+
JSON
.
stringify
(
error
));
...
...
@@ -330,7 +330,7 @@ isOperationAllowed(): Promise<boolean>
-
示例:
```
```
js
wallpaper
.
isOperationAllowed
().
then
((
data
)
=>
{
console
.
log
(
`success to isOperationAllowed: `
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
...
...
@@ -357,7 +357,7 @@ reset(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void
-
示例:
```
```
js
wallpaper
.
reset
(
wallpaper
.
WallpaperType
.
WALLPAPER_SYSTEM
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
error
(
`failed to reset because: `
+
JSON
.
stringify
(
error
));
...
...
@@ -390,7 +390,7 @@ reset(wallpaperType: WallpaperType): Promise<void>
-
示例:
```
```
js
wallpaper
.
reset
(
wallpaper
.
WallpaperType
.
WALLPAPER_SYSTEM
).
then
((
data
)
=>
{
console
.
log
(
`success to reset.`
);
}).
catch
((
error
)
=>
{
...
...
@@ -418,7 +418,7 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, call
-
示例:
```
```
js
// source类型为string
let
wallpaperPath
=
"
/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg
"
;
wallpaper
.
setWallpaper
(
wallpaperPath
,
wallpaper
.
WallpaperType
.
WALLPAPER_SYSTEM
,
(
error
,
data
)
=>
{
...
...
@@ -475,7 +475,7 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Pro
-
示例:
```
```
js
// source类型为string
let
wallpaperPath
=
"
/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg
"
;
wallpaper
.
setWallpaper
(
wallpaperPath
,
wallpaper
.
WallpaperType
.
WALLPAPER_SYSTEM
).
then
((
data
)
=>
{
...
...
@@ -522,7 +522,7 @@ getFile(wallpaperType: WallpaperType, callback: AsyncCallback<number>): vo
-
示例:
```
```
js
wallpaper
.
getFile
(
wallpaper
.
WallpaperType
.
WALLPAPER_SYSTEM
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
error
(
`failed to getFile because: `
+
JSON
.
stringify
(
error
));
...
...
@@ -554,7 +554,7 @@ getFile(wallpaperType: WallpaperType): Promise<number>
-
示例:
```
```
js
wallpaper
.
getFile
(
wallpaper
.
WallpaperType
.
WALLPAPER_SYSTEM
).
then
((
data
)
=>
{
console
.
log
(
`success to getFile: `
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
...
...
@@ -579,7 +579,7 @@ on(type: 'colorChange', callback: (colors: Array<RgbaColor>, wallpaperType
-
示例:
```
```
js
let
listener
=
(
colors
,
wallpaperType
)
=>
{
console
.
log
(
`wallpaper color changed.`
);
};
...
...
@@ -603,7 +603,7 @@ off(type: 'colorChange', callback?: (colors: Array<RgbaColor>, wallpaperTy
-
示例:
```
```
js
let
listener
=
(
colors
,
wallpaperType
)
=>
{
console
.
log
(
`wallpaper color changed.`
);
};
...
...
@@ -619,7 +619,7 @@ off(type: 'colorChange', callback?: (colors: Array<RgbaColor>, wallpaperTy
**系统能力**
: 以下各项对应的系统能力均为SystemCapability.MiscServices.Wallpaper。
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| red | number | 是 | 是 | 表示红色值,范围为
0
到
255。 |
| green | number | 是 | 是 | 表示绿色值,范围为
0
到
255。 |
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录