提交 223abcfc 编写于 作者: S siyuan.liu

update js-apis-distributed-data.md

Signed-off-by: Nsiyuan.liu <siyuan.liu@unionman.com.cn>
上级 e5c05ab2
...@@ -72,28 +72,23 @@ FA模型下的示例: ...@@ -72,28 +72,23 @@ FA模型下的示例:
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
let kvManager; let kvManager;
export default class MyAbility { let context = featureAbility.getContext()
onCreate() { const kvManagerConfig = {
console.log("MyAbilityStage onCreate") context: context,
let context = featureAbility.getContext() bundleName: 'com.example.datamanagertest',
const kvManagerConfig = { userInfo: {
context: context, userId: '0',
bundleName: 'com.example.datamanagertest', userType: distributedData.UserType.SAME_USER_ID
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;
});
} }
} }
distributedData.createKVManager(kvManagerConfig, function (err, manager) {
if (err) {
console.log("Failed to create KVManager: " + JSON.stringify(err));
return;
}
console.log("Created KVManager");
kvManager = manager;
});
``` ```
## distributedData.createKVManager ## distributedData.createKVManager
...@@ -148,26 +143,21 @@ FA模型下的示例: ...@@ -148,26 +143,21 @@ FA模型下的示例:
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
let kvManager; let kvManager;
export default class MyAbility { let context = featureAbility.getContext()
onCreate() { const kvManagerConfig = {
console.log("MyAbilityStage onCreate") context: context,
let context = featureAbility.getContext() bundleName: 'com.example.datamanagertest',
const kvManagerConfig = { userInfo: {
context: context, userId: '0',
bundleName: 'com.example.datamanagertest', userType: distributedData.UserType.SAME_USER_ID
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));
});
``` ```
## KVManagerConfig ## KVManagerConfig
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册