Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
7ab54cbf
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看板
未验证
提交
7ab54cbf
编写于
7月 11, 2023
作者:
O
openharmony_ci
提交者:
Gitee
7月 11, 2023
浏览文件
操作
浏览文件
下载
差异文件
!20656 优化ArkTS卡片开发指南中的示例代码
Merge pull request !20656 from zhongjianfei/mm0710
上级
8e3653b2
2b93a76e
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
20 addition
and
20 deletion
+20
-20
zh-cn/application-dev/application-models/arkts-ui-widget-update-by-status.md
...ev/application-models/arkts-ui-widget-update-by-status.md
+20
-20
未找到文件。
zh-cn/application-dev/application-models/arkts-ui-widget-update-by-status.md
浏览文件 @
7ab54cbf
...
...
@@ -104,11 +104,11 @@
if
(
isTempCard
===
false
)
{
// 如果为常态卡片,直接进行信息持久化
console
.
info
(
'
Not temp card, init db for:
'
+
formId
);
let
promise
=
dataPreferences
.
getPreferences
(
this
.
context
,
'
myStore
'
);
promise
.
then
((
storeDB
)
=>
{
promise
.
then
(
async
(
storeDB
)
=>
{
console
.
info
(
"
Succeeded to get preferences.
"
);
storeDB
.
putSync
(
'
A
'
+
formId
,
'
false
'
);
storeDB
.
putSync
(
'
B
'
+
formId
,
'
false
'
);
storeDB
.
flush
();
await
storeDB
.
put
(
'
A
'
+
formId
,
'
false
'
);
await
storeDB
.
put
(
'
B
'
+
formId
,
'
false
'
);
await
storeDB
.
flush
();
}).
catch
((
err
)
=>
{
console
.
info
(
`Failed to get preferences.
${
JSON
.
stringify
(
err
)}
`
);
})
...
...
@@ -120,10 +120,10 @@
onRemoveForm
(
formId
)
{
console
.
info
(
'
onRemoveForm, formId:
'
+
formId
);
let
promise
=
dataPreferences
.
getPreferences
(
this
.
context
,
'
myStore
'
);
promise
.
then
((
storeDB
)
=>
{
promise
.
then
(
async
(
storeDB
)
=>
{
console
.
info
(
"
Succeeded to get preferences.
"
);
storeDB
.
deleteSync
(
'
A
'
+
formId
);
storeDB
.
deleteSync
(
'
B
'
+
formId
);
await
storeDB
.
delete
(
'
A
'
+
formId
);
await
storeDB
.
delete
(
'
B
'
+
formId
);
}).
catch
((
err
)
=>
{
console
.
info
(
`Failed to get preferences.
${
JSON
.
stringify
(
err
)}
`
);
})
...
...
@@ -133,11 +133,11 @@
onCastToNormalForm
(
formId
)
{
console
.
info
(
'
onCastToNormalForm, formId:
'
+
formId
);
let
promise
=
dataPreferences
.
getPreferences
(
this
.
context
,
'
myStore
'
);
promise
.
then
((
storeDB
)
=>
{
promise
.
then
(
async
(
storeDB
)
=>
{
console
.
info
(
"
Succeeded to get preferences.
"
);
storeDB
.
putSync
(
'
A
'
+
formId
,
'
false
'
);
storeDB
.
putSync
(
'
B
'
+
formId
,
'
false
'
);
storeDB
.
flush
();
await
storeDB
.
put
(
'
A
'
+
formId
,
'
false
'
);
await
storeDB
.
put
(
'
B
'
+
formId
,
'
false
'
);
await
storeDB
.
flush
();
}).
catch
((
err
)
=>
{
console
.
info
(
`Failed to get preferences.
${
JSON
.
stringify
(
err
)}
`
);
})
...
...
@@ -145,19 +145,19 @@
onUpdateForm
(
formId
)
{
let
promise
=
dataPreferences
.
getPreferences
(
this
.
context
,
'
myStore
'
);
promise
.
then
((
storeDB
)
=>
{
promise
.
then
(
async
(
storeDB
)
=>
{
console
.
info
(
"
Succeeded to get preferences.
"
);
let
stateA
=
storeDB
.
getSync
(
'
A
'
+
formId
,
'
false
'
).
toString
(
);
let
stateB
=
storeDB
.
getSync
(
'
B
'
+
formId
,
'
false
'
).
toString
(
);
let
stateA
=
await
storeDB
.
get
(
'
A
'
+
formId
,
'
false
'
);
let
stateB
=
await
storeDB
.
get
(
'
B
'
+
formId
,
'
false
'
);
// A状态选中则更新textA
if
(
stateA
===
'
true
'
)
{
let
formInfo
=
formBindingData
.
createFormBindingData
({
'
textA
'
:
'
AAA
'
});
formProvider
.
updateForm
(
formId
,
formInfo
);
await
formProvider
.
updateForm
(
formId
,
formInfo
);
}
// B状态选中则更新textB
if
(
stateB
===
'
true
'
)
{
let
formInfo
=
formBindingData
.
createFormBindingData
({
'
textB
'
:
'
BBB
'
});
formProvider
.
updateForm
(
formId
,
formInfo
);
await
formProvider
.
updateForm
(
formId
,
formInfo
);
}
console
.
info
(
`Update form success stateA:
${
stateA
}
stateB:
${
stateB
}
.`
);
}).
catch
((
err
)
=>
{
...
...
@@ -169,18 +169,18 @@
// 存放卡片状态
console
.
info
(
'
onFormEvent formId:
'
+
formId
+
'
msg:
'
+
message
);
let
promise
=
dataPreferences
.
getPreferences
(
this
.
context
,
'
myStore
'
);
promise
.
then
((
storeDB
)
=>
{
promise
.
then
(
async
(
storeDB
)
=>
{
console
.
info
(
"
Succeeded to get preferences.
"
);
let
msg
=
JSON
.
parse
(
message
);
if
(
msg
.
selectA
!=
undefined
)
{
console
.
info
(
'
onFormEvent selectA info:
'
+
msg
.
selectA
);
storeDB
.
putSync
(
'
A
'
+
formId
,
msg
.
selectA
);
await
storeDB
.
put
(
'
A
'
+
formId
,
msg
.
selectA
);
}
if
(
msg
.
selectB
!=
undefined
)
{
console
.
info
(
'
onFormEvent selectB info:
'
+
msg
.
selectB
);
storeDB
.
putSync
(
'
B
'
+
formId
,
msg
.
selectB
);
await
storeDB
.
put
(
'
B
'
+
formId
,
msg
.
selectB
);
}
storeDB
.
flush
();
await
storeDB
.
flush
();
}).
catch
((
err
)
=>
{
console
.
info
(
`Failed to get preferences.
${
JSON
.
stringify
(
err
)}
`
);
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录