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

无法在外部获得广播事件 #11533

Open
zbl400 opened this issue Jan 22, 2025 · 0 comments
Open

无法在外部获得广播事件 #11533

zbl400 opened this issue Jan 22, 2025 · 0 comments

Comments

@zbl400
Copy link

zbl400 commented Jan 22, 2025

描述问题:

代码混合开发的模式中, 使用 onBroadcast 无法在外部获取 broadcast 事件
console 中能看到 amis 的日志 “run action broadcast”
但是无法看到 外部 handleBroadcast 响应函数中的 console 日志

截图或视频:

Image

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

  1. 你是如何使用 amis 的?
    react 版本

  2. amis 版本是什么?请先在最新 beta 版本测试问题是否存在
    6.10.0

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

let amisJSON = {
  type: 'page',
  title: '表单页面',
  body: [
    {
      type: 'form',
      mode: 'horizontal',
      onEvent: {
        submitSucc: {
          actions: [
            {
              actionType: 'broadcast',
              args: {
                eventName: 'formSubmited'
              }
            }
          ]
        }
      },
      body: [
        {
          label: 'Name',
          type: 'input-text',
          name: 'name'
        },
        {
          type: 'submit',
          label: 'Submit'
        }
      ]
    }
  ]
};

import {render as renderAmis} from 'amis';

function DemoComponent() {
  function handleBroadcast(type: string, rawEvent: any, data: any) {
    console.log(type);
    if (type === 'formSubmited') {
      console.log('内部表单提交了');
    }
  }

  return <div>
    {renderAmis(amisJSON, {onBroadcast: handleBroadcast})}
  </div>
};
  1. 操作步骤
    参见
    https://codesandbox.io/p/devbox/amis-broadcast-d8pvfl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant