关闭行为 负责 Telegram Mini Apps 关闭行为 的💠组件。 安装在使用该组件之前,有必要将其安装到配置正确的 属性中。 为此,请使用 mount 方法。 它将更新 isMounted 信号属性。 Variable : - import { closingBehavior } from '@telegram-apps/sdk';
% U% b+ Z0 p& X4 J+ O - ) p9 o* u. U0 Y* O
- closingBehavior.mount();( L5 `) ]" |# M/ _/ o! e$ d- Y6 {9 p
- closingBehavior.isMounted(); // true
复制代码Functions : - import {
: v; i- b, |/ i& R) p5 j - mountClosingBehavior,/ Z6 O8 S0 A7 m: ~5 ?
- isClosingBehaviorMounted,
& V7 N% D4 d. q - } from '@telegram-apps/sdk';6 O" G, H/ J: ?8 E
; D& t- T6 Q# S2 I- mountClosingBehavior();
+ Y. r9 N+ e6 L/ A: c - isClosingBehaviorMounted(); // true
复制代码 8 ^! ~: @! g2 E0 ?6 v: ~
要卸载,请使用 unmount 方法: Variable : - closingBehavior.unmount();$ D# u' H: E3 ?4 v
- closingBehavior.isMounted(); // false
复制代码Functions : - import {
L. x+ D7 m4 I8 m ?' U - unmountClosingBehavior,2 Y2 t' E! j& m1 M: k3 C
- isClosingBehaviorMounted,' i% y: z# S& t x
- } from '@telegram-apps/sdk';
% G/ ?3 O) q; n# a! q& K
1 i; p# x3 R6 i3 J( w- I6 [" b& @- unmountClosingBehavior();
6 u, k/ u7 n8 i8 Q R$ @. F - isClosingBehaviorMounted(); // false
复制代码 关闭确认要更改关闭确认行为,请使用 enableConfirmation() 和 disableConfirmation() 方法。 这些方法会更新 isConfirmationEnabled 信号 的属性值。 Variable : - closingBehavior.enableConfirmation();
9 l$ x/ B8 {1 E6 _ - closingBehavior.isConfirmationEnabled(); // true
3 c& o. `4 b, S# a1 ?
- B' E* @) I: z8 @- closingBehavior.disableConfirmation();
# X& ^+ j% Z" ]7 _ - closingBehavior.isConfirmationEnabled(); // false
复制代码Functions : - import {
- |6 {: Y9 Q% i8 W a - enableClosingConfirmation,
6 _! u+ m% g; c* k# J - disableClosingConfirmation,4 n, F& r4 [2 R
- } from '@telegram-apps/sdk';6 j% R7 r. G+ ]& l$ W
- # v% `. I9 w Y: I/ t; ?9 W# Q9 I
- enableClosingConfirmation();2 @1 x6 ]# w, f( l+ P4 b
- isClosingConfirmationEnabled(); // true
3 u n& _" e- m - 0 a1 z. x+ N# n7 M& u! H1 ~$ G' k
- disableClosingConfirmation();6 V' f9 S0 M; j! k+ z0 [
- isClosingConfirmationEnabled(); // false
复制代码 ) Y/ r; k4 ~9 L* P' r
- v0 U+ z, K! k1 G; d+ Z- d$ b
|