提交 0391cdf7 编写于 作者: S siyuan.liu

update js-apis-distributed-data.md

Signed-off-by: Nsiyuan.liu <siyuan.liu@unionman.com.cn>
上级 223abcfc
......@@ -45,26 +45,26 @@ Stage模型下的示例:
import AbilityStage from '@ohos.application.Ability'
let kvManager;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
let context = this.context
const kvManagerConfig = {
context: context,
bundleName: 'com.example.datamanagertest',
userInfo: {
userId: '0',
userType: distributedData.UserType.SAME_USER_ID
}
onCreate() {
console.log("MyAbilityStage onCreate")
let context = this.context
const kvManagerConfig = {
context: context,
bundleName: 'com.example.datamanagertest',
userInfo: {
userId: '0',
userType: distributedData.UserType.SAME_USER_ID
}
}
distributedData.createKVManager(kvManagerConfig, function (err, manager) {
if (err) {
console.log("Failed to create KVManager: " + JSON.stringify(err));
return;
}
console.log("Succeeded in creating KVManager");
kvManager = manager;
});
}
distributedData.createKVManager(kvManagerConfig, function (err, manager) {
if (err) {
console.log("Failed to create KVManager: " + JSON.stringify(err));
return;
}
console.log("Succeeded in creating KVManager");
kvManager = manager;
});
}
}
```
......@@ -74,20 +74,20 @@ import featureAbility from '@ohos.ability.featureAbility'
let kvManager;
let context = featureAbility.getContext()
const kvManagerConfig = {
context: context,
bundleName: 'com.example.datamanagertest',
userInfo: {
userId: '0',
userType: distributedData.UserType.SAME_USER_ID
}
context: context,
bundleName: 'com.example.datamanagertest',
userInfo: {
userId: '0',
userType: distributedData.UserType.SAME_USER_ID
}
}
distributedData.createKVManager(kvManagerConfig, function (err, manager) {
if (err) {
console.log("Failed to create KVManager: " + JSON.stringify(err));
return;
}
console.log("Created KVManager");
kvManager = manager;
if (err) {
console.log("Failed to create KVManager: " + JSON.stringify(err));
return;
}
console.log("Created KVManager");
kvManager = manager;
});
```
......@@ -118,24 +118,24 @@ Stage模型下的示例:
import AbilityStage from '@ohos.application.Ability'
let kvManager;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
let context = this.context
const kvManagerConfig = {
context: context,
bundleName: 'com.example.datamanagertest',
userInfo: {
userId: '0',
userType: distributedData.UserType.SAME_USER_ID
}
onCreate() {
console.log("MyAbilityStage onCreate")
let context = this.context
const kvManagerConfig = {
context: context,
bundleName: 'com.example.datamanagertest',
userInfo: {
userId: '0',
userType: distributedData.UserType.SAME_USER_ID
}
}
distributedData.createKVManager(kvManagerConfig).then((manager) => {
console.log("Succeeded in creating KVManager");
kvManager = manager;
}).catch((err) => {
console.log("Failed to create KVManager: " + JSON.stringify(err));
});
}
distributedData.createKVManager(kvManagerConfig).then((manager) => {
console.log("Succeeded in creating KVManager");
kvManager = manager;
}).catch((err) => {
console.log("Failed to create KVManager: " + JSON.stringify(err));
});
}
}
```
......@@ -145,18 +145,18 @@ import featureAbility from '@ohos.ability.featureAbility'
let kvManager;
let context = featureAbility.getContext()
const kvManagerConfig = {
context: context,
bundleName: 'com.example.datamanagertest',
userInfo: {
userId: '0',
userType: distributedData.UserType.SAME_USER_ID
}
context: context,
bundleName: 'com.example.datamanagertest',
userInfo: {
userId: '0',
userType: distributedData.UserType.SAME_USER_ID
}
}
distributedData.createKVManager(kvManagerConfig).then((manager) => {
console.log("Succeeded in creating KVManager");
kvManager = manager;
console.log("Succeeded in creating KVManager");
kvManager = manager;
}).catch((err) => {
console.log("Failed to create KVManager: " + JSON.stringify(err));
console.log("Failed to create KVManager: " + JSON.stringify(err));
});
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册