Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第一次事件无法获取 page.data 中的最新值,第二次可以,为什么? #11396

Open
lishengliang74 opened this issue Dec 18, 2024 · 2 comments

Comments

@lishengliang74
Copy link

现象:

页面:data 下的 val 的值预先设置 1
按钮:点击会设置 page 组件下的 val = 3
多选框:值变化后会弹框显示 val 的值,第一次事件会弹出消息 1,以后在持续改变多选框,则显示正确的值 3
按钮2:点击后会弹框显示 val 的值,可以正确显示 val 的值 3。

amis 版本:6.5.0

问题:为什么会出现首次拿不到 val 的最新的值的问题?除了多选框、单选框也同样的问题。

schema:

{
"type": "page",
"title": "test",
"body": [
{
"type": "button",
"label": "看 val 的值",
"onEvent": {
"click": {
"actions": [
{
"ignoreError": false,
"actionType": "toast",
"args": {
"msgType": "info",
"position": "top-right",
"closeButton": true,
"showIcon": true,
"msg": "${val}",
"className": "theme-toast-action-scope"
}
}
]
}
},
"id": "u:28b14233deef"
},
{
"type": "checkboxes",
"label": "点击看 val 的值",
"name": "checkboxes",
"multiple": true,
"options": [
{
"label": "选项A",
"value": "A"
},
{
"label": "选项B",
"value": "B"
}
],
"id": "u:dc8b8c0dbb61",
"checkAll": false,
"joinValues": true,
"onEvent": {
"change": {
"weight": 0,
"actions": [
{
"ignoreError": false,
"actionType": "toast",
"args": {
"msgType": "info",
"position": "top-right",
"closeButton": true,
"showIcon": true,
"msg": "${val}",
"className": "theme-toast-action-scope"
}
}
]
}
}
},
{
"type": "button",
"label": "让 val = 3",
"onEvent": {
"click": {
"actions": [
{
"componentId": "u:965d34da3acd",
"ignoreError": false,
"actionType": "setValue",
"args": {
"value": {
"val": "3"
}
}
}
]
}
},
"id": "u:11b667ec4650"
}
],
"regions": [
"body",
"header"
],
"id": "u:965d34da3acd",
"pullRefresh": {
"disabled": true
},
"onEvent": {
"init": {
"weight": 0,
"actions": [
{
"componentId": "u:965d34da3acd",
"ignoreError": false,
"actionType": "setValue",
"args": {
"value": {
"val": "2"
}
}
}
]
}
},
"data": {
"val": 1
}
}

@lishengliang74
Copy link
Author

发现一个属性:strictMode,要设置为 false。设置为 false 后就能正常获取到最新的值了。

@lishengliang74
Copy link
Author

在官方的文档网站上,直接编辑某个例子,没有输入strictMode = false,结果也是好的。这个属性有点诡异,到底什么时候需要用设置,什么时候默认生效?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant