amis icon indicating copy to clipboard operation
amis copied to clipboard

修改输入框,快速点击确定按钮,自定义JS的event.data无法获取表单数据,即使加延时也不行

Open wanquantong opened this issue 8 months ago • 4 comments

描述问题:

修改输入框,快速点击确定按钮,自定义JS的event.data无法获取表单数据,即使加延时也不行。

如下图, 第一次:填写了输入框,快速点击确定按钮,没有输出数据。 第二次:填写了输入框,等一会,再点击确定按钮,输出了数据。

Image

如何复现(请务必完整填写下面内容):

  1. 你是如何使用 amis 的? sdk Amis 6.12

  2. 粘贴有问题的完整 amis schema 代码:

{
  "type": "page",
  "title": "",
  "body": [
    {
      "type": "button",
      "label": "弹窗",
      "onEvent": {
        "click": {
          "actions": [
            {
              "ignoreError": false,
              "actionType": "dialog",
              "dialog": {
                "$ref": "modal-ref-1"
              }
            }
          ]
        }
      },
      "id": "u:0645afda4492",
      "disabledOnAction": false
    }
  ],
  "id": "u:e49bf0505641",
  "asideResizor": false,
  "pullRefresh": {
    "disabled": true
  },
  "regions": [
    "body"
  ],
  "definitions": {
    "modal-ref-1": {
      "type": "dialog",
      "body": [
        {
          "type": "form",
          "id": "u:b06deedcf3c2",
          "title": "",
          "mode": "horizontal",
          "labelAlign": "left",
          "dsType": "api",
          "feat": "Edit",
          "body": [
            {
              "type": "input-text",
              "label": "test5.A",
              "name": "test5.A",
              "showSteps": false,
              "keyboard": true,
              "id": "u:ea36743787d5"
            }
          ],
          "actions": [
            {
              "type": "button",
              "label": "确定",
              "onEvent": {
                "click": {
                  "actions": [
                    {
                      "actionType": "submit",
                      "componentId": "u:b06deedcf3c2"
                    }
                  ]
                }
              },
              "level": "primary",
              "id": "u:09312a7ae2d2",
              "disabledOnAction": false
            }
          ],
          "resetAfterSubmit": true,
          "initApi": "",
          "wrapWithPanel": false,
          "rules": [],
          "closeDialogOnSubmit": false,
          "debug": false
        }
      ],
      "title": "修改",
      "id": "u:2ad075f127e2",
      "actions": [
        {
          "type": "button",
          "actionType": "cancel",
          "label": "取消",
          "id": "u:57ae6a6da72f",
          "disabledOnAction": false
        },
        {
          "type": "button",
          "actionType": "confirm",
          "label": "确定",
          "primary": true,
          "id": "u:7257ec52e9bd",
          "disabledOnAction": false,
          "onEvent": {
            "click": {
              "weight": 0,
              "actions": [
                {
                  "ignoreError": false,
                  "actionType": "custom",
                  "args": {},
                  "script": "\r\nsetTimeout(function () {\r\n  console.log('这条消息将在2秒后显示');\r\n  console.log(event.data.test5.A);\r\n}, 2000);"
                }
              ]
            }
          },
          "close": false
        }
      ],
      "showCloseButton": true,
      "closeOnOutside": false,
      "closeOnEsc": false,
      "showErrorMsg": false,
      "showLoading": true,
      "draggable": false,
      "size": "sm"
    }
  },
  "onEvent": {
    "init": {
      "weight": 0,
      "actions": [
        {
          "ignoreError": false,
          "actionType": "dialog",
          "dialog": {
            "$ref": "modal-ref-1"
          }
        }
      ]
    }
  },
  "data": {
    "a": "[]"
  }
}

wanquantong avatar Apr 18 '25 09:04 wanquantong

👍 Thanks for this! 🏷 I have applied any labels matching special text in your issue.

Please review the labels and make any necessary changes.

github-actions[bot] avatar Apr 18 '25 09:04 github-actions[bot]

event.data 不是说已经要废弃掉了。 有没有什么替代的方法可以调用。

xmlijian avatar Apr 29 '25 09:04 xmlijian

换个方式,用id获取到渲染示例,完美成功,多用debugger调试能发现新大陆

event.context.scoped.getComponentById("bbbid").state.inputValue;

🚀 欢迎加入最大的,人数最多的,含佬量极高的Amis社区群👇

🌟Amis社区交流群【QQ1群】:717791727

🌟Amis社区交流群【QQ2群】:721182449

lhtuling avatar May 12 '25 12:05 lhtuling

event.data 不是说已经要废弃掉了。 有没有什么替代的方法可以调用。

看我上面回复

🚀 欢迎加入最大的,人数最多的,含佬量极高的Amis社区群👇

🌟Amis社区交流群【QQ1群】:717791727

🌟Amis社区交流群【QQ2群】:721182449

lhtuling avatar May 12 '25 12:05 lhtuling