本帖最后由 riyad 于 2025-2-22 20:49 编辑
, f4 ^/ v& Z: E8 @: N+ _6 B0 ^% O3 C: l6 q, p" C* ?9 i
执行 Telegram Mini Apps 关闭行为 功能。
, h0 h/ G/ C/ ~9 ]) r9 T' P- E9 _1 B" U4 O% J' k
初始要初始化组件,请使用 initClosingBehavior 函数: - import { initClosingBehavior } from '@telegram-apps/sdk';
2 ?# \! r, p) W0 I! ` - 3 |5 `0 `) A: R
- const [closingBehavior] = initClosingBehavior();
复制代码 闭幕确要启用或禁用关闭确认,需要使用 enableConfirmation() 和 disableConfirmation() 方法。 这些方法会更新 isConfirmationNeeded 属性: 3 u* N; B3 M6 i0 U. U8 Z$ s
- closingBehavior.enableConfirmation();
; i/ w5 I6 E |7 H7 | - console.log(closingBehavior.isConfirmationNeeded); // true & Z% ], z6 _+ L* i% p7 D
9 s0 |$ V* r$ J5 G |5 X6 e- closingBehavior.disableConfirmation();
* h% n" K% M: {0 f9 O; { - console.log(closingBehavior.isConfirmationNeeded); // false
复制代码 事件可被 跟踪 的事件列表: [td]事件 | 监听函数 | 触发条件 | change | () => void | 组件中的某些部分发生了变化 | change:isConfirmationNeeded | (value: boolean) => void | 已更改 isConfirmationNeeded 属性 | 7 w+ }$ ]# D# m3 u
( y6 Q }! N* ?$ S: T
1 N) p; k2 o' a) W |