English 简体中文 繁體中文 한국 사람 日本語 Deutsch русский بالعربية TÜRKÇE português คนไทย french

简体中文 繁體中文 English 日本語 Deutsch 한국 사람 بالعربية TÜRKÇE คนไทย Français русский

回答

收藏

Telegram 小程序 | TypeScript @telegram-apps/sdk @2.x | 组件 | 关闭行为

开源社区 开源社区 7952 人阅读 | 0 人回复 | 2025-02-24

关闭行为

负责 Telegram Mini Apps 关闭行为 的💠组件

安装

在使用该组件之前,有必要将其安装到配置正确的 属性中。 为此,请使用 mount 方法。 它将更新 isMounted 信号属性。

Variable :

  1. import { closingBehavior } from '@telegram-apps/sdk';
    % U% b+ Z0 p& X4 J+ O
  2. ) p9 o* u. U0 Y* O
  3. closingBehavior.mount();( L5 `) ]" |# M/ _/ o! e$ d- Y6 {9 p
  4. closingBehavior.isMounted(); // true
复制代码

Functions :

  1. import {
    : v; i- b, |/ i& R) p5 j
  2.   mountClosingBehavior,/ Z6 O8 S0 A7 m: ~5 ?
  3.   isClosingBehaviorMounted,
    & V7 N% D4 d. q
  4. } from '@telegram-apps/sdk';6 O" G, H/ J: ?8 E

  5. ; D& t- T6 Q# S2 I
  6. mountClosingBehavior();
    + Y. r9 N+ e6 L/ A: c
  7. isClosingBehaviorMounted(); // true
复制代码
8 ^! ~: @! g2 E0 ?6 v: ~

要卸载,请使用 unmount 方法:

Variable :

  1. closingBehavior.unmount();$ D# u' H: E3 ?4 v
  2. closingBehavior.isMounted(); // false
复制代码

Functions :

  1. import {
      L. x+ D7 m4 I8 m  ?' U
  2.   unmountClosingBehavior,2 Y2 t' E! j& m1 M: k3 C
  3.   isClosingBehaviorMounted,' i% y: z# S& t  x
  4. } from '@telegram-apps/sdk';
    % G/ ?3 O) q; n# a! q& K

  5. 1 i; p# x3 R6 i3 J( w- I6 [" b& @
  6. unmountClosingBehavior();
    6 u, k/ u7 n8 i8 Q  R$ @. F
  7. isClosingBehaviorMounted(); //  false
复制代码
关闭确认

要更改关闭确认行为,请使用 enableConfirmation() 和 disableConfirmation() 方法。 这些方法会更新 isConfirmationEnabled 信号 的属性值。

Variable :

  1. closingBehavior.enableConfirmation();
    9 l$ x/ B8 {1 E6 _
  2. closingBehavior.isConfirmationEnabled(); // true
    3 c& o. `4 b, S# a1 ?

  3. - B' E* @) I: z8 @
  4. closingBehavior.disableConfirmation();
    # X& ^+ j% Z" ]7 _
  5. closingBehavior.isConfirmationEnabled(); // false
复制代码

Functions :

  1. import {
    - |6 {: Y9 Q% i8 W  a
  2.   enableClosingConfirmation,
    6 _! u+ m% g; c* k# J
  3.   disableClosingConfirmation,4 n, F& r4 [2 R
  4. } from '@telegram-apps/sdk';6 j% R7 r. G+ ]& l$ W
  5. # v% `. I9 w  Y: I/ t; ?9 W# Q9 I
  6. enableClosingConfirmation();2 @1 x6 ]# w, f( l+ P4 b
  7. isClosingConfirmationEnabled(); // true
    3 u  n& _" e- m
  8. 0 a1 z. x+ N# n7 M& u! H1 ~$ G' k
  9. disableClosingConfirmation();6 V' f9 S0 M; j! k+ z0 [
  10. isClosingConfirmationEnabled(); // false
复制代码
) Y/ r; k4 ~9 L* P' r
- v0 U+ z, K! k1 G; d+ Z- d$ b
分享到:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则