tmagic-editor/docs/runtime-api/core/eventHelper.html
2026-11-05 11:36:05 +00:00

45 lines
26 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>EventHelper | tmagic-editor</title>
<meta name="description" content="页面可视化平台">
<meta name="generator" content="VitePress v2.0.0-alpha.20">
<link rel="preload stylesheet" href="/tmagic-editor/docs/assets/style.BJ2NNEpv.css" as="style">
<link rel="preload stylesheet" href="/tmagic-editor/docs/assets/vp-icons.139f4833.css" as="style">
<script type="module" src="/tmagic-editor/docs/assets/chunks/metadata.dcccadd9.js"></script>
<script type="module" src="/tmagic-editor/docs/assets/app.CPR846ZD.js"></script>
<link rel="preload" href="/tmagic-editor/docs/assets/inter-roman-latin.q5rAVC0E.woff2" as="font" type="font/woff2" crossorigin="">
<link rel="modulepreload" href="/tmagic-editor/docs/assets/chunks/framework.xVFRZL1t.js">
<link rel="modulepreload" href="/tmagic-editor/docs/assets/chunks/theme.Cnor0NYZ.js">
<link rel="modulepreload" href="/tmagic-editor/docs/assets/runtime-api_core_eventHelper.md.DbOfNm6Q.lean.js">
<meta name="theme-color" content="#646cff">
<script id="check-dark-mode">(()=>{let e=localStorage.getItem(`vitepress-theme-appearance`)||`auto`,t=window.matchMedia(`(prefers-color-scheme: dark)`).matches;(!e||e===`auto`?t:e===`dark`)&&document.documentElement.classList.add(`dark`)})();</script>
<script id="check-mac-os">document.documentElement.classList.toggle(`mac`,/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
</head>
<body>
<div id="app"><div class="Layout" data-v-30dd6aed><!--[--><!--]--><!--[--><span tabindex="-1" data-v-a433cfaa></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-a433cfaa>Skip to content</a><!--]--><!----><header class="VPNav" data-v-30dd6aed data-v-07bd5c5d><div class="VPNavBar has-sidebar top" data-v-07bd5c5d data-v-21941f7c><div class="wrapper" data-v-21941f7c><div class="container" data-v-21941f7c><div class="title" data-v-21941f7c><div class="VPNavBarTitle has-sidebar" data-v-21941f7c data-v-897088ca><a class="title" href="/tmagic-editor/docs/" title="tmagic-editor" data-v-897088ca><!--[--><!--]--><!--[--><img class="VPImage logo" src="./favicon.png" alt data-v-38e748df><!--]--><span data-v-897088ca>tmagic-editor</span><!--[--><!--]--></a></div></div><div class="content" data-v-21941f7c><div class="content-body" data-v-21941f7c><!--[--><!--]--><div class="VPNavBarSearch search" data-v-21941f7c data-v-f5079369><!--[--><button type="button" class="VPNavBarSearchButton" aria-label="Search" aria-keyshortcuts="/ control+k meta+k" data-v-f5079369 data-v-83aac609><span class="vpi-search" aria-hidden="true" data-v-83aac609></span><span class="text" data-v-83aac609>Search</span><span class="keys" aria-hidden="true" data-v-83aac609><kbd class="key-mod" data-v-83aac609></kbd><kbd class="key-k" data-v-83aac609></kbd></span></button><!----><!--]--></div><nav aria-label="Main Navigation" class="VPNavMenu VPNavBarMenu menu" data-v-21941f7c data-v-4ba09fef><ul class="list" data-v-4ba09fef><!--[--><li class="" data-v-4ba09fef><a class="VPLink link VPNavMenuLink VPNavBarMenuLink" href="/tmagic-editor/docs/guide/" data-v-4ba09fef data-v-7e03ec29><!--[--><span data-v-7e03ec29>文档</span><!--]--></a></li><li class="" data-v-4ba09fef><a class="VPLink link VPNavMenuLink VPNavBarMenuLink" href="/tmagic-editor/docs/api/editor/props.html" data-v-4ba09fef data-v-7e03ec29><!--[--><span data-v-7e03ec29>Editor API</span><!--]--></a></li><li class="" data-v-4ba09fef><a class="VPLink link VPNavMenuLink VPNavBarMenuLink active" href="/tmagic-editor/docs/runtime-api/core/app.html" data-v-4ba09fef data-v-7e03ec29><!--[--><span data-v-7e03ec29>Runtime API</span><!--]--></a></li><li class="" data-v-4ba09fef><a class="VPLink link VPNavMenuLink VPNavBarMenuLink" href="/tmagic-editor/docs/form-config/fields/text.html" data-v-4ba09fef data-v-7e03ec29><!--[--><span data-v-7e03ec29>表单配置</span><!--]--></a></li><li class="" data-v-4ba09fef><a class="VPLink link vp-external-link-icon VPNavMenuLink VPNavBarMenuLink" href="https://github.com/Tencent/tmagic-editor/releases" target="_blank" rel="noreferrer" data-v-4ba09fef data-v-7e03ec29><!--[--><span data-v-7e03ec29>更新日志</span><!--]--></a></li><li class="" data-v-4ba09fef><a class="VPLink link vp-external-link-icon VPNavMenuLink VPNavBarMenuLink" href="https://tencent.github.io/tmagic-editor/playground/index.html" target="_blank" rel="noreferrer" data-v-4ba09fef data-v-7e03ec29><!--[--><span data-v-7e03ec29>Playground</span><!--]--></a></li><!--]--></ul></nav><!----><div class="VPNavAppearance VPNavBarAppearance appearance" data-v-21941f7c data-v-f5ba90e0><!----><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-label="Appearance" aria-checked="false" data-v-f5ba90e0 data-v-dd1ff0a1 data-v-cbe52c7c><span class="check" data-v-cbe52c7c><span class="icon" data-v-cbe52c7c><!--[--><span class="vpi-sun sun" aria-hidden="true" data-v-dd1ff0a1></span><span class="vpi-moon moon" aria-hidden="true" data-v-dd1ff0a1></span><!--]--></span></span></button></div><ul class="VPSocialLinks VPNavSocialLinks VPNavBarSocialLinks social-links" data-v-21941f7c data-v-552b8346 data-v-677dc98a><!--[--><li data-v-677dc98a><a class="VPSocialLink no-icon" href="https://github.com/Tencent/tmagic-editor" aria-label="github" target="_blank" rel="me noopener" data-v-677dc98a data-v-9979aee9><span class="vpi-simple-icons-github" data-v-9979aee9 data-v-8056d6c9></span></a></li><!--]--></ul><!----><!--[--><!--]--><button type="button" class="VPNavBarHamburger hamburger" aria-label="Menu" aria-expanded="false" data-v-21941f7c data-v-5bed391b><span class="container" aria-hidden="true" data-v-5bed391b><span class="top" data-v-5bed391b></span><span class="middle" data-v-5bed391b></span><span class="bottom" data-v-5bed391b></span></span></button></div></div></div></div><div class="divider" data-v-21941f7c><div class="divider-line" data-v-21941f7c></div></div></div><!----></header><div class="VPLocalNav has-sidebar empty" data-v-30dd6aed data-v-194cf01f><div class="container" data-v-194cf01f><button type="button" class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-194cf01f><span class="vpi-align-left menu-icon" aria-hidden="true" data-v-194cf01f></span><span class="menu-text" data-v-194cf01f>Menu</span></button><div class="VPLocalNavOutlineDropdown" style="--vp-vh:0px;" data-allow-mismatch="style" data-v-194cf01f data-v-5b4c2295><button type="button" data-v-5b4c2295>Return to top</button><!----></div></div></div><aside class="VPSidebar" data-v-30dd6aed data-v-86dd7c4e><div class="curtain" data-v-86dd7c4e></div><nav class="nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-86dd7c4e><span class="visually-hidden" id="sidebar-aria-label" data-v-86dd7c4e> Sidebar Navigation </span><!--[--><!--]--><!--[--><div class="no-transition group" data-v-e9f7a9fe><section class="VPSidebarItem level-0 has-active" data-v-e9f7a9fe data-v-83833344><div class="item" data-v-83833344><div class="indicator" data-v-83833344></div><h2 class="text" data-v-83833344>@tmagic/core</h2><!----></div><ul class="items" data-v-83833344><li data-v-83833344><!--[--><div class="VPSidebarItem level-1 is-link" data-v-83833344><div class="item" data-v-83833344><div class="indicator" data-v-83833344></div><a class="VPLink link link" href="/tmagic-editor/docs/runtime-api/core/app.html" data-v-83833344><!--[--><p class="text" data-v-83833344>App</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-83833344><div class="item" data-v-83833344><div class="indicator" data-v-83833344></div><a class="VPLink link link" href="/tmagic-editor/docs/runtime-api/core/node.html" data-v-83833344><!--[--><p class="text" data-v-83833344>Node</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-83833344><div class="item" data-v-83833344><div class="indicator" data-v-83833344></div><a class="VPLink link link" href="/tmagic-editor/docs/runtime-api/core/page.html" data-v-83833344><!--[--><p class="text" data-v-83833344>Page</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link is-active has-active" data-v-83833344><div class="item" data-v-83833344><div class="indicator" data-v-83833344></div><a class="VPLink link link" href="/tmagic-editor/docs/runtime-api/core/eventHelper.html" aria-current="page" data-v-83833344><!--[--><p class="text" data-v-83833344>EventHelper</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-83833344><div class="item" data-v-83833344><div class="indicator" data-v-83833344></div><a class="VPLink link link" href="/tmagic-editor/docs/runtime-api/core/env.html" data-v-83833344><!--[--><p class="text" data-v-83833344>Env</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-83833344><div class="item" data-v-83833344><div class="indicator" data-v-83833344></div><a class="VPLink link link" href="/tmagic-editor/docs/runtime-api/core/iteratorContainer.html" data-v-83833344><!--[--><p class="text" data-v-83833344>IteratorContainer</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-83833344><div class="item" data-v-83833344><div class="indicator" data-v-83833344></div><a class="VPLink link link" href="/tmagic-editor/docs/runtime-api/core/flowState.html" data-v-83833344><!--[--><p class="text" data-v-83833344>FlowState</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-83833344><div class="item" data-v-83833344><div class="indicator" data-v-83833344></div><a class="VPLink link link" href="/tmagic-editor/docs/runtime-api/core/devtoolApi.html" data-v-83833344><!--[--><p class="text" data-v-83833344>DevtoolApi</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-83833344><div class="item" data-v-83833344><div class="indicator" data-v-83833344></div><a class="VPLink link link" href="/tmagic-editor/docs/runtime-api/core/utils.html" data-v-83833344><!--[--><p class="text" data-v-83833344>工具函数</p><!--]--></a><!----></div><!----></div><!--]--></li></ul></section></div><div class="no-transition group" data-v-e9f7a9fe><section class="VPSidebarItem level-0" data-v-e9f7a9fe data-v-83833344><div class="item" data-v-83833344><div class="indicator" data-v-83833344></div><h2 class="text" data-v-83833344>@tmagic/data-source</h2><!----></div><ul class="items" data-v-83833344><li data-v-83833344><!--[--><div class="VPSidebarItem level-1 is-link" data-v-83833344><div class="item" data-v-83833344><div class="indicator" data-v-83833344></div><a class="VPLink link link" href="/tmagic-editor/docs/runtime-api/data-source/dataSourceManager.html" data-v-83833344><!--[--><p class="text" data-v-83833344>DataSourceManager</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-83833344><div class="item" data-v-83833344><div class="indicator" data-v-83833344></div><a class="VPLink link link" href="/tmagic-editor/docs/runtime-api/data-source/dataSource.html" data-v-83833344><!--[--><p class="text" data-v-83833344>DataSource</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-83833344><div class="item" data-v-83833344><div class="indicator" data-v-83833344></div><a class="VPLink link link" href="/tmagic-editor/docs/runtime-api/data-source/httpDataSource.html" data-v-83833344><!--[--><p class="text" data-v-83833344>HttpDataSource</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-83833344><div class="item" data-v-83833344><div class="indicator" data-v-83833344></div><a class="VPLink link link" href="/tmagic-editor/docs/runtime-api/data-source/observedData.html" data-v-83833344><!--[--><p class="text" data-v-83833344>观察者数据类</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-83833344><div class="item" data-v-83833344><div class="indicator" data-v-83833344></div><a class="VPLink link link" href="/tmagic-editor/docs/runtime-api/data-source/utils.html" data-v-83833344><!--[--><p class="text" data-v-83833344>工具函数</p><!--]--></a><!----></div><!----></div><!--]--></li></ul></section></div><!--]--><!--[--><!--]--></nav></aside><div class="VPContent has-sidebar" id="VPContent" data-v-30dd6aed data-v-67626bf1><div class="VPDoc has-sidebar has-aside" data-v-67626bf1 data-v-d7746812><!--[--><!--]--><div class="container" data-v-d7746812><div class="aside" data-v-d7746812><div class="aside-curtain" data-v-d7746812></div><div class="aside-container" data-v-d7746812><div class="aside-content" data-v-d7746812><div class="VPDocAside" data-v-d7746812 data-v-c57c5106><!--[--><!--]--><!--[--><!--]--><nav aria-labelledby="doc-outline-aria-label" class="VPDocAsideOutline" data-v-c57c5106 data-v-44783068><div class="content" data-v-44783068><div class="outline-marker" data-v-44783068></div><div aria-level="2" class="outline-title" id="doc-outline-aria-label" role="heading" data-v-44783068>On this page</div><ul class="VPDocOutlineItem root" data-v-44783068 data-v-78fca9da><!--[--><!--]--></ul></div></nav><!--[--><!--]--><div class="spacer" data-v-c57c5106></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><div class="content" data-v-d7746812><div class="content-container" data-v-d7746812><!--[--><!--]--><main class="main" data-v-d7746812><div style="position:relative;" class="vp-doc _tmagic-editor_docs_runtime-api_core_eventHelper" data-v-d7746812><div><h1 id="eventhelper" tabindex="-1">EventHelper <a class="header-anchor" href="#eventhelper" aria-label="Permalink to “EventHelper”">​</a></h1><p><code>EventHelper</code> 是 <code>@tmagic/core</code> 的事件助手类,继承自 <code>EventEmitter</code>,用于管理组件间的事件联动。</p><h2 id="构造函数" tabindex="-1">构造函数 <a class="header-anchor" href="#构造函数" aria-label="Permalink to “构造函数”">​</a></h2><div class="language-typescript"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">typescript</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#c62739;--shiki-dark:#F97583;">new</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> EventHelper</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(options: EventHelperOptions)</span></span></code></pre></div><h3 id="eventhelperoptions" tabindex="-1">EventHelperOptions <a class="header-anchor" href="#eventhelperoptions" aria-label="Permalink to “EventHelperOptions”">​</a></h3><table tabindex="0"><thead><tr><th>参数</th><th>类型</th><th>说明</th></tr></thead><tbody><tr><td><code>app</code></td><td><code>App</code></td><td>应用实例</td></tr><tr><td><code>beforeEventHandler</code></td><td><code>BeforeEventHandler</code></td><td>事件处理前钩子(可选),形如 <code>({ eventConfig, source, args }) =&gt; void</code></td></tr><tr><td><code>afterEventHandler</code></td><td><code>AfterEventHandler</code></td><td>事件处理后钩子(可选),形如 <code>({ eventConfig, source, args }) =&gt; void</code></td></tr></tbody></table><h2 id="属性" tabindex="-1">属性 <a class="header-anchor" href="#属性" aria-label="Permalink to “属性”">​</a></h2><table tabindex="0"><thead><tr><th>属性</th><th>类型</th><th>说明</th></tr></thead><tbody><tr><td><code>app</code></td><td><code>App</code></td><td>应用实例</td></tr><tr><td><code>eventQueue</code></td><td><code>EventCache[]</code></td><td>暂存的待处理事件队列(参见 <code>getEventQueue</code>)</td></tr></tbody></table><h2 id="实例方法" tabindex="-1">实例方法 <a class="header-anchor" href="#实例方法" aria-label="Permalink to “实例方法”">​</a></h2><h3 id="initevents" tabindex="-1">initEvents <a class="header-anchor" href="#initevents" aria-label="Permalink to “initEvents”">​</a></h3><ul><li><p><strong>返回:</strong></p><ul><li><code>{void}</code></li></ul></li><li><p><strong>详情:</strong></p><p>初始化所有节点的事件。通常在页面加载时调用。</p></li><li><p><strong>示例:</strong></p></li></ul><div class="language-typescript"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">typescript</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">eventHelper.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">initEvents</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">();</span></span></code></pre></div><h3 id="bindnodeevents" tabindex="-1">bindNodeEvents <a class="header-anchor" href="#bindnodeevents" aria-label="Permalink to “bindNodeEvents”">​</a></h3><ul><li><p><strong>参数:</strong></p><ul><li><code>{Node} node</code> 节点实例</li></ul></li><li><p><strong>返回:</strong></p><ul><li><code>{void}</code></li></ul></li><li><p><strong>详情:</strong></p><p>为单个节点绑定事件处理。</p></li><li><p><strong>示例:</strong></p></li></ul><div class="language-typescript"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">typescript</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">eventHelper.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">bindNodeEvents</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(node);</span></span></code></pre></div><h3 id="removenodeevents" tabindex="-1">removeNodeEvents <a class="header-anchor" href="#removenodeevents" aria-label="Permalink to “removeNodeEvents”">​</a></h3><ul><li><p><strong>返回:</strong></p><ul><li><code>{void}</code></li></ul></li><li><p><strong>详情:</strong></p><p>移除所有节点的事件绑定。</p></li></ul><h3 id="binddatasourceevents" tabindex="-1">bindDataSourceEvents <a class="header-anchor" href="#binddatasourceevents" aria-label="Permalink to “bindDataSourceEvents”">​</a></h3><ul><li><p><strong>返回:</strong></p><ul><li><code>{void}</code></li></ul></li><li><p><strong>详情:</strong></p><p>绑定数据源事件,监听数据源变化并触发相应的组件更新。</p></li></ul><h3 id="removedatasourceevents" tabindex="-1">removeDataSourceEvents <a class="header-anchor" href="#removedatasourceevents" aria-label="Permalink to “removeDataSourceEvents”">​</a></h3><ul><li><p><strong>参数:</strong></p><ul><li><code>{DataSource[]} dataSourceList</code> 数据源实例列表(必填)</li></ul></li><li><p><strong>返回:</strong></p><ul><li><code>{void}</code></li></ul></li><li><p><strong>详情:</strong></p><p>移除给定数据源的事件绑定。内部根据已注册的事件名前缀,调用 <code>dataSource.offDataChange</code> 或 <code>dataSource.off</code> 注销监听,并清空 <code>dataSourceEventList</code>。</p></li></ul><h3 id="geteventqueue" tabindex="-1">getEventQueue <a class="header-anchor" href="#geteventqueue" aria-label="Permalink to “getEventQueue”">​</a></h3><ul><li><p><strong>返回:</strong></p><ul><li><code>{EventCache[]}</code> 事件缓存项数组,每项形如 <code>{ toId: Id, method: string, fromCpt: any, args: any[], handled?: boolean }</code></li></ul></li><li><p><strong>详情:</strong></p><p>获取当前事件队列。当目标节点尚未挂载时,联动事件会被缓存到此队列;目标节点 <code>mounted</code> 后,会消费匹配项并调用其 <code>instance</code> 上的对应方法。</p></li></ul><h3 id="addeventtoqueue" tabindex="-1">addEventToQueue <a class="header-anchor" href="#addeventtoqueue" aria-label="Permalink to “addEventToQueue”">​</a></h3><ul><li><p><strong>参数:</strong></p><ul><li><code>{EventCache} event</code> 事件缓存项,形如 <code>{ toId: Id, method: string, fromCpt: any, args: any[] }</code></li></ul></li><li><p><strong>返回:</strong></p><ul><li><code>{void}</code></li></ul></li><li><p><strong>详情:</strong></p><p>将事件添加到队列中等待处理。</p></li></ul><h3 id="destroy" tabindex="-1">destroy <a class="header-anchor" href="#destroy" aria-label="Permalink to “destroy”">​</a></h3><ul><li><p><strong>返回:</strong></p><ul><li><code>{void}</code></li></ul></li><li><p><strong>详情:</strong></p><p>销毁事件助手,清理所有事件绑定。</p></li></ul><h2 id="支持的动作类型" tabindex="-1">支持的动作类型 <a class="header-anchor" href="#支持的动作类型" aria-label="Permalink to “支持的动作类型”">​</a></h2><p>EventHelper 支持以下动作类型(ActionType):</p><table tabindex="0"><thead><tr><th>类型</th><th>说明</th></tr></thead><tbody><tr><td><code>ActionType.COMP</code></td><td>组件动作,调用目标组件的方法</td></tr><tr><td><code>ActionType.CODE</code></td><td>代码块执行</td></tr><tr><td><code>ActionType.DATA_SOURCE</code></td><td>数据源方法调用</td></tr></tbody></table><h3 id="事件配置示例" tabindex="-1">事件配置示例 <a class="header-anchor" href="#事件配置示例" aria-label="Permalink to “事件配置示例”">​</a></h3><div class="language-typescript"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">typescript</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#c62739;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> eventConfig</span><span style="--shiki-light:#c62739;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> name: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;click&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> actions: [</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> actionType: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;comp&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> to: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;button_2&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> method: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;show&#39;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> },</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> actionType: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;code&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> codeId: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;code_1&#39;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> },</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> actionType: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;dataSource&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> dataSourceId: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;ds_1&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> methodName: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;fetchData&#39;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ]</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">};</span></span></code></pre></div></div></div></main><footer class="VPDocFooter" data-v-d7746812 data-v-5edf9672><!--[--><!--]--><!----><nav class="prev-next" aria-labelledby="doc-footer-aria-label" data-v-5edf9672><span class="visually-hidden" id="doc-footer-aria-label" data-v-5edf9672>Pager</span><div class="pager" data-v-5edf9672><a class="VPLink link pager-link prev" href="/tmagic-editor/docs/runtime-api/core/page.html" data-v-5edf9672><!--[--><span class="desc" data-v-5edf9672>Previous page</span><span class="title" data-v-5edf9672>Page</span><!--]--></a></div><div class="pager" data-v-5edf9672><a class="VPLink link pager-link next" href="/tmagic-editor/docs/runtime-api/core/env.html" data-v-5edf9672><!--[--><span class="desc" data-v-5edf9672>Next page</span><span class="title" data-v-5edf9672>Env</span><!--]--></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><footer class="VPFooter has-sidebar" data-v-30dd6aed data-v-58cefbd9><div class="container" data-v-58cefbd9><p class="message" data-v-58cefbd9>Powered by 腾讯视频会员平台技术中心</p><p class="copyright" data-v-58cefbd9>Copyright (C) 2025 Tencent.</p></div></footer><!--[--><!--]--></div></div>
</body>
</html>