Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
69c02c65
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看板
未验证
提交
69c02c65
编写于
2月 25, 2022
作者:
O
openharmony_ci
提交者:
Gitee
2月 25, 2022
浏览文件
操作
浏览文件
下载
差异文件
!1620 修改老的文档示例代码
Merge pull request !1620 from 刘宝/master
上级
2bd85f81
9d7dd8d6
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
63 addition
and
57 deletion
+63
-57
zh-cn/application-dev/reference/apis/js-apis-Context.md
zh-cn/application-dev/reference/apis/js-apis-Context.md
+11
-11
zh-cn/application-dev/reference/apis/js-apis-DataUriUtils.md
zh-cn/application-dev/reference/apis/js-apis-DataUriUtils.md
+3
-7
zh-cn/application-dev/reference/apis/js-apis-ability-context.md
...application-dev/reference/apis/js-apis-ability-context.md
+3
-3
zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md
...plication-dev/reference/apis/js-apis-dataAbilityHelper.md
+7
-7
zh-cn/application-dev/reference/apis/js-apis-particleAbility.md
...application-dev/reference/apis/js-apis-particleAbility.md
+13
-11
zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md
...n-dev/reference/apis/js-apis-service-extension-context.md
+11
-11
zh-cn/application-dev/reference/apis/js-apis-service-extension.md
...plication-dev/reference/apis/js-apis-service-extension.md
+15
-7
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-Context.md
浏览文件 @
69c02c65
...
...
@@ -63,7 +63,7 @@ getOrCreateLocalDir(): Promise\<string>
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
context
=
featureAbility
.
getContext
();
context
.
getOrCreateLocalDir
().
then
((
void
)
=>
{
context
.
getOrCreateLocalDir
().
then
(()
=>
{
console
.
info
(
"
==========================>getOrCreateLocalDirCallback=======================>
"
);
});
```
...
...
@@ -91,9 +91,9 @@ verifyPermission(permission: string, options: PermissionOptions, callback: Async
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
bundle
from
'
@ohos.bundle
'
var
context
=
featureAbility
.
getContext
();
var
datainfo
=
await
bundle
.
getBundleInfo
(
'
com.context.test
'
,
1
);
context
.
verifyPermission
(
"
com.example.permission
"
,
datainfo
.
uid
)
bundle
.
getBundleInfo
(
'
com.context.test
'
,
1
,
(
datainfo
)
=>
{
context
.
verifyPermission
(
"
com.example.permission
"
,
datainfo
.
uid
);
});
```
...
...
@@ -146,7 +146,7 @@ verifyPermission(permission: string, options?: PermissionOptions): Promise\<numb
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
context
=
featureAbility
.
getContext
();
var
Permission
=
context
.
PermissionOptions
(
1
,
1
);
context
.
getOrCreateLocalDir
(
'
com.context.permission
'
,
Permission
).
then
((
void
)
=>
{
context
.
getOrCreateLocalDir
(
'
com.context.permission
'
,
Permission
).
then
(()
=>
{
console
.
info
(
"
==========================>verifyPermissionCallback=======================>
"
);
});
```
...
...
@@ -223,7 +223,7 @@ getApplicationInfo(): Promise\<ApplicationInfo>
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
context
=
featureAbility
.
getContext
();
context
.
getApplicationInfo
().
then
((
void
)
=>
{
context
.
getApplicationInfo
().
then
(()
=>
{
console
.
info
(
"
==========================>getApplicationInfoCallback=======================>
"
);
});
```
...
...
@@ -269,7 +269,7 @@ getBundleName(): Promise\<string>
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
context
=
featureAbility
.
getContext
();
context
.
getBundleName
().
then
((
void
)
=>
{
context
.
getBundleName
().
then
(()
=>
{
console
.
info
(
"
==========================>getBundleNameCallback=======================>
"
);
});
```
...
...
@@ -315,7 +315,7 @@ getProcessInfo(): Promise\<ProcessInfo>
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
context
=
featureAbility
.
getContext
();
context
.
getProcessInfo
().
then
((
void
)
=>
{
context
.
getProcessInfo
().
then
(()
=>
{
console
.
info
(
"
==========================>getProcessInfoCallback=======================>
"
);
});
```
...
...
@@ -365,7 +365,7 @@ getElementName(): Promise\<ElementName>
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
context
=
featureAbility
.
getContext
();
context
.
getElementName
().
then
((
void
)
=>
{
context
.
getElementName
().
then
(()
=>
{
console
.
info
(
"
==========================>getElementNameCallback=======================>
"
);
});
```
...
...
@@ -407,7 +407,7 @@ getProcessName(): Promise\<string>
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
context
=
featureAbility
.
getContext
();
context
.
getProcessName
().
then
((
void
)
=>
{
context
.
getProcessName
().
then
(()
=>
{
console
.
info
(
"
==========================>getProcessNameCallback=======================>
"
);
});
```
...
...
@@ -453,7 +453,7 @@ getCallingBundle(): Promise\<string>
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
context
=
featureAbility
.
getContext
();
context
.
getCallingBundle
().
then
((
void
)
=>
{
context
.
getCallingBundle
().
then
(()
=>
{
console
.
info
(
"
==========================>getCallingBundleCallback=======================>
"
);
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-DataUriUtils.md
浏览文件 @
69c02c65
...
...
@@ -27,7 +27,6 @@ getId(uri: string): number
**示例:**
```
js
import
dataUriUtils
from
'
@ohos.ability.datauriutils
'
dataUriUtils
.
getIdSync
(
"
com.example.dataUriUtils/1221
"
)
```
...
...
@@ -55,10 +54,9 @@ attachId(uri: string, id: number): string
**示例:**
```
js
import
dataUriUtils
from
'
@ohos.ability.datauriutils
'
var
idint
=
1122
;
dataUriUtils
.
attachId
(
"
com.example.dataUriUtils
"
"
com.example.dataUriUtils
"
,
idint
,
)
```
...
...
@@ -85,7 +83,6 @@ deleteId(uri: string): string
**示例:**
```
js
import
dataUriUtils
from
'
@ohos.ability.datauriutils
'
dataUriUtils
.
deleteId
(
"
com.example.dataUriUtils/1221
"
)
```
...
...
@@ -112,11 +109,10 @@ updateId(uri: string, id: number): string
**示例:**
```
js
import
dataUriUtils
from
'
@ohos.ability.datauriutils
'
var
idint
=
1122
;
dataUriUtils
.
updateId
(
"
com.example.dataUriUtils
"
idint
,
"
com.example.dataUriUtils
"
,
idint
)
```
zh-cn/application-dev/reference/apis/js-apis-ability-context.md
浏览文件 @
69c02c65
...
...
@@ -137,8 +137,8 @@ terminateSelf(callback: AsyncCallback<void>): void;
-
示例:
```
this.context.terminateSelf((err) => {
console.log('terminateSelf result:' + JSON.stringfy(err);
}
console.log('terminateSelf result:' + JSON.stringfy(err)
)
;
}
);
```
...
...
@@ -157,7 +157,7 @@ terminateSelf(): Promise<void>;
```
this.context.terminateSelf(want).then((data) => {
console.log('success:' + JSON.stringfy(data));
)
).catch((error) => {
}
).catch((error) => {
console.log('failed:' + JSON.stringfy(error));
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md
浏览文件 @
69c02c65
...
...
@@ -65,8 +65,8 @@ var DAHelper = featureAbility.acquireDataAbilityHelper(
);
var
mode
=
"
rwt
"
;
DAHelper
.
openFile
(
"
dataability:///com.example.DataAbility
"
,
mode
).
then
((
void
)
=>
{
"
dataability:///com.example.DataAbility
"
,
mode
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>openFileCallback=======================>
"
);
});
```
...
...
@@ -338,7 +338,7 @@ var DAHelper = featureAbility.acquireDataAbilityHelper(
"
dataability:///com.example.DataAbility
"
);
DAHelper
.
denormalizeUri
(
"
dataability:///com.example.DataAbility
"
,
,
"
dataability:///com.example.DataAbility
"
,
(
err
,
data
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
});
...
...
@@ -398,7 +398,7 @@ var helper = featureAbility.acquireDataAbilityHelper(
"
dataability:///com.example.DataAbility
"
);
helper
.
notifyChange
(
"
dataability:///com.example.DataAbility
"
,
,
"
dataability:///com.example.DataAbility
"
,
(
err
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
});
...
...
@@ -430,7 +430,7 @@ var DAHelper = featureAbility.acquireDataAbilityHelper(
);
DAHelper
.
notifyChange
(
"
dataability:///com.example.DataAbility
"
,
).
then
((
void
)
=>
{
).
then
(()
=>
{
console
.
info
(
"
==========================>notifyChangeCallback=======================>
"
);
});
```
...
...
@@ -747,7 +747,7 @@ import ohos_data_ability from '@ohos.data.dataability'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
var
cars
=
new
Array
(
{
"
value1
"
},
{
"
value2
"
},
{
"
value3
"
},
{
"
value4
"
}
);
var
cars
=
new
Array
(
"
value1
"
,
"
value2
"
,
"
value3
"
,
"
value4
"
);
let
da
=
new
ohos_data_ability
.
DataAbilityPredicates
()
DAHelper
.
query
(
"
dataability:///com.example.DataAbility
"
,
...
...
@@ -787,7 +787,7 @@ import ohos_data_ability from '@ohos.data.dataability'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
var
cars
=
new
Array
(
{
"
value1
"
},
{
"
value2
"
},
{
"
value3
"
},
{
"
value4
"
}
);
var
cars
=
new
Array
(
"
value1
"
,
"
value2
"
,
"
value3
"
,
"
value4
"
);
let
da
=
new
ohos_data_ability
.
DataAbilityPredicates
()
DAHelper
.
query
(
"
dataability:///com.example.DataAbility
"
,
...
...
zh-cn/application-dev/reference/apis/js-apis-particleAbility.md
浏览文件 @
69c02c65
...
...
@@ -28,6 +28,7 @@ startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\<void>: v
```
js
import
particleAbility
from
'
@ohos.ability.particleAbility
'
import
wantConstant
from
"
@ohos.ability.wantConstant
"
particleAbility
.
startAbility
(
{
want
:
...
...
@@ -35,7 +36,7 @@ particleAbility.startAbility(
action
:
"
action.system.home
"
,
entities
:
[
"
entity.system.home
"
],
type
:
"
MIMETYPE
"
,
flags
:
FLAG_AUTH_READ_URI_PERMISSION
;
flags
:
wantConstant
.
Flags
.
FLAG_AUTH_READ_URI_PERMISSION
,
deviceId
:
""
,
bundleName
:
"
com.example.Data
"
,
abilityName
:
"
com.example.Data.MainAbility
"
,
...
...
@@ -70,6 +71,7 @@ startAbility(parameter: StartAbilityParameter): Promise\<number>
```
js
import
particleAbility
from
'
@ohos.ability.particleAbility
'
import
wantConstant
from
"
@ohos.ability.wantConstant
"
particleAbility
.
startAbility
(
{
want
:
...
...
@@ -77,14 +79,14 @@ particleAbility.startAbility(
action
:
"
action.system.home
"
,
entities
:
[
"
entity.system.home
"
],
type
:
"
MIMETYPE
"
,
flags
:
FLAG_AUTH_READ_URI_PERMISSION
;
flags
:
wantConstant
.
Flags
.
FLAG_AUTH_READ_URI_PERMISSION
,
deviceId
:
""
,
bundleName
:
"
com.example.Data
"
,
abilityName
:
"
com.example.Data.MainAbility
"
,
abilityName
:
"
com.example.
Data.MainAbility
"
,
uri
:
""
},
},
).
then
((
void
)
=>
{
).
then
(()
=>
{
console
.
info
(
"
particleAbility startAbility
"
);
});
```
...
...
@@ -131,7 +133,7 @@ terminateSelf(): Promise\<void>
```
js
import
particleAbility
from
'
@ohos.ability.particleAbility
'
particleAbility
.
terminateSelf
().
then
((
void
)
=>
{
particleAbility
.
terminateSelf
().
then
(()
=>
{
console
.
info
(
"
particleAbility terminateSelf
"
);
});
```
...
...
@@ -195,7 +197,7 @@ connectAbility(request: Want, options:ConnectOptions): number
```
javascript
import
particleAbility
from
'
@ohos.ability.particleAbility
'
function
onConnectCallback
(
element
,
remote
){
console
.
log
(
'
ConnectAbility onConnect
remote is proxy:
'
+
(
remote
instanceof
rpc
.
RemoteProxy
)
);
console
.
log
(
'
ConnectAbility onConnect
Callback
'
);
}
function
onDisconnectCallback
(
element
){
console
.
log
(
'
ConnectAbility onDisconnect element.deviceId :
'
+
element
.
deviceId
)
...
...
@@ -234,7 +236,7 @@ disconnectAbility(connection: number, callback:AsyncCallback\<void>): void
```
javascript
import
particleAbility
from
'
@ohos.ability.particleAbility
'
function
onConnectCallback
(
element
,
remote
){
console
.
log
(
'
ConnectAbility onConnect
remote is proxy:
'
+
(
remote
instanceof
rpc
.
RemoteProxy
)
);
console
.
log
(
'
ConnectAbility onConnect
Callback
'
);
}
function
onDisconnectCallback
(
element
){
console
.
log
(
'
ConnectAbility onDisconnect element.deviceId :
'
+
element
.
deviceId
)
...
...
@@ -255,8 +257,8 @@ var connId = particleAbility.connectAbility(
);
var
result
=
particleAbility
.
disconnectAbility
(
connId
,
(
error
,
data
)
=>
{
console
.
log
(
'
particleAbilityTest DisConnectAbility result errCode :
'
+
error
.
code
+
"
data:
"
+
data
)
}
,
console
.
log
(
'
particleAbilityTest DisConnectAbility result errCode :
'
+
error
.
code
+
"
data:
"
+
data
)
;
}
);
```
...
...
@@ -282,7 +284,7 @@ disconnectAbility(connection: number): Promise\<void>
```
javascript
import
particleAbility
from
'
@ohos.ability.particleAbility
'
function
onConnectCallback
(
element
,
remote
){
console
.
log
(
'
ConnectAbility onConnect
remote is proxy:
'
+
(
remote
instanceof
rpc
.
RemoteProxy
)
);
console
.
log
(
'
ConnectAbility onConnect
onConnectCallback
'
);
}
function
onDisconnectCallback
(
element
){
console
.
log
(
'
ConnectAbility onDisconnect element.deviceId :
'
+
element
.
deviceId
)
...
...
@@ -301,7 +303,7 @@ var connId = particleAbility.connectAbility(
onFailed
:
onFailedCallback
,
},
);
var
result
=
particleAbility
.
disconnectAbility
(
connId
).
then
((
void
)
=>
{
var
result
=
particleAbility
.
disconnectAbility
(
connId
).
then
(()
=>
{
console
.
info
(
"
particleAbilityTest disconnectAbility
"
);
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md
浏览文件 @
69c02c65
...
...
@@ -29,8 +29,8 @@ startAbility(want: Want, callback: AsyncCallback<void>): void;
"abilityName": "com.example.myapp.MyAbility"
};
this.context.startAbility(want, (err) => {
console.log('startAbility result:' + JSON.stringfy(err);
}
console.log('startAbility result:' + JSON.stringfy(err)
)
;
}
);
```
...
...
@@ -58,7 +58,7 @@ startAbility(want: Want): Promise<void>;
};
this.context.startAbility(want).then((data) => {
console.log('success:' + JSON.stringfy(data));
)
).catch((error) => {
}
).catch((error) => {
console.log('failed:' + JSON.stringfy(error));
});
```
...
...
@@ -78,8 +78,8 @@ terminateSelf(callback: AsyncCallback<void>): void;
-
示例:
```
this.context.terminateSelf((err) => {
console.log('terminateSelf result:' + JSON.stringfy(err);
}
console.log('terminateSelf result:' + JSON.stringfy(err)
)
;
}
);
```
...
...
@@ -98,7 +98,7 @@ terminateSelf(): Promise<void>;
```
this.context.terminateSelf(want).then((data) => {
console.log('success:' + JSON.stringfy(data));
)
).catch((error) => {
}
).catch((error) => {
console.log('failed:' + JSON.stringfy(error));
});
```
...
...
@@ -128,8 +128,8 @@ connectAbility(want: Want, options: ConnectOptions): number;
"abilityName": "com.example.myapp.MyAbility"
};
let options = {
onConnect: function(elementName, proxy) {}
onDisConnect: function(elementName) {}
onConnect: function(elementName, proxy) {}
,
onDisConnect: function(elementName) {}
,
onFailed: function(code) {}
}
let connection = this.context.connectAbility(want,options);
...
...
@@ -151,8 +151,8 @@ disconnectAbility(connection: number, callback:AsyncCallback<void>): void;
-
示例:
```
this.context.disconnectAbility(connection, (err) => { // connection为connectAbility中的返回值
console.log('terminateSelf result:' + JSON.stringfy(err);
}
console.log('terminateSelf result:' + JSON.stringfy(err)
)
;
}
);
```
...
...
@@ -176,7 +176,7 @@ disconnectAbility(connection: number): Promise<void>;
```
this.context.disconnectAbility(connection).then((data) => { // connection为connectAbility中的返回值
console.log('success:' + JSON.stringfy(data));
)
).catch((error) => {
}
).catch((error) => {
console.log('failed:' + JSON.stringfy(error));
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-service-extension.md
浏览文件 @
69c02c65
...
...
@@ -39,8 +39,10 @@ Extension生命周期回调,在创建时回调,执行初始化业务逻辑
-
示例:
```
onCreate(want) {
class ServiceExt extends ServiceExtension {
onCreate(want) {
console.log('onCreate, want:' + want.abilityName);
}
}
```
...
...
@@ -53,9 +55,10 @@ Extension生命周期回调,在销毁时回调,执行资源清理等操作
-
示例:
```
onDestroy() {
class ServiceExt extends ServiceExtension {
onDestroy() {
console.log('onDestroy');
destory();
}
}
```
...
...
@@ -74,8 +77,10 @@ Extension生命周期回调,如果是startAbility拉起的服务,会在onCre
-
示例:
```
onRequest(want: Want, startId: number) {
class ServiceExt extends ServiceExtension {
onRequest(want, startId) {
console.log('onRequest, want:' + want.abilityName);
}
}
```
...
...
@@ -106,10 +111,11 @@ Extension生命周期回调,如果是connectAbility拉起的服务,会在onC
onRemoteRequest(code, data, reply, option) {
}
}
...
onConnect(want) {
class ServiceExt extends ServiceExtension {
onConnect(want) {
console.log('onConnect , want:' + want.abilityName);
return new StubTest("test");
}
}
```
...
...
@@ -127,7 +133,9 @@ Extension的生命周期,断开服务连接时回调。
-
示例:
```
onDisconnect(want) {
class ServiceExt extends ServiceExtension {
onDisconnect(want) {
console.log('onDisconnect, want:' + want.abilityName);
}
}
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录