From 135c759590925641a5167e3ee72f2d648d294951 Mon Sep 17 00:00:00 2001 From: WX997659 <10038940+wx997659@user.noreply.gitee.com> Date: Sun, 24 Apr 2022 08:36:52 +0000 Subject: [PATCH] =?UTF-8?q?update=20Data/JsDistributedData/entry/src/main/?= =?UTF-8?q?js/MainAbility/pages/index/index.js.=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entry/src/main/js/MainAbility/pages/index/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Data/JsDistributedData/entry/src/main/js/MainAbility/pages/index/index.js b/Data/JsDistributedData/entry/src/main/js/MainAbility/pages/index/index.js index addaaa3e..42edbab1 100644 --- a/Data/JsDistributedData/entry/src/main/js/MainAbility/pages/index/index.js +++ b/Data/JsDistributedData/entry/src/main/js/MainAbility/pages/index/index.js @@ -14,6 +14,7 @@ */ import KvStoreModel from '../../../model/KvStoreModel.js'; +import featureAbility from '@ohos.ability.featureAbility'; export default { data: { @@ -28,6 +29,7 @@ export default { }, onInit() { this.title = this.$t('strings.world'); + this.grantPermission(); // type表示操作0:插入数据、1:修改数据:2:删除数据 this.kvStoreModel.setOnMessageReceivedListener((k, y, type) => { @@ -46,6 +48,13 @@ export default { } }); }, + grantPermission() { + console.info('Calc[IndexPage] grantPermission') + let context = featureAbility.getContext() + context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) { + console.info(`Calc[IndexPage] grantPermission,requestPermissionsFromUser,result.requestCode=${result.requestCode}`) + }) + }, getIndex(key) { for (let i = 0; i < this.contactList.length; i++) { -- Gitee