@tarojs/taro 3.3.12 → 3.3.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/types/api/ad/index.d.ts +34 -28
- package/types/api/alipay/index.d.ts +11 -7
- package/types/api/base/debug.d.ts +60 -54
- package/types/api/base/env.d.ts +12 -8
- package/types/api/base/index.d.ts +87 -83
- package/types/api/base/system.d.ts +59 -54
- package/types/api/base/update.d.ts +37 -33
- package/types/api/base/weapp/app-event.d.ts +147 -131
- package/types/api/base/weapp/life-cycle.d.ts +14 -10
- package/types/api/canvas/index.d.ts +115 -110
- package/types/api/cloud/index.d.ts +99 -94
- package/types/api/data-analysis/index.d.ts +68 -64
- package/types/api/device/accelerometer.d.ts +57 -50
- package/types/api/device/battery.d.ts +19 -15
- package/types/api/device/ble.d.ts +241 -228
- package/types/api/device/bluetooth.d.ts +207 -194
- package/types/api/device/clipboard.d.ts +48 -43
- package/types/api/device/compass.d.ts +55 -48
- package/types/api/device/contact.d.ts +13 -9
- package/types/api/device/gyroscope.d.ts +41 -35
- package/types/api/device/iBeacon.d.ts +79 -73
- package/types/api/device/motion.d.ts +42 -37
- package/types/api/device/network.d.ts +80 -42
- package/types/api/device/nfc.d.ts +105 -96
- package/types/api/device/performance.d.ts +32 -18
- package/types/api/device/phone.d.ts +20 -15
- package/types/api/device/scan.d.ts +31 -26
- package/types/api/device/screen.d.ts +74 -67
- package/types/api/device/vibrate.d.ts +31 -25
- package/types/api/device/wifi.d.ts +151 -140
- package/types/api/ext/index.d.ts +44 -39
- package/types/api/files/index.d.ts +219 -209
- package/types/api/framework/index.d.ts +25 -20
- package/types/api/location/index.d.ts +140 -136
- package/types/api/media/audio.d.ts +135 -127
- package/types/api/media/background-audio.d.ts +135 -126
- package/types/api/media/camera.d.ts +30 -26
- package/types/api/media/editor.d.ts +35 -33
- package/types/api/media/image.d.ts +161 -150
- package/types/api/media/live.d.ts +88 -82
- package/types/api/media/map.d.ts +47 -43
- package/types/api/media/recorder.d.ts +90 -84
- package/types/api/media/video-processing.d.ts +10 -6
- package/types/api/media/video.d.ts +63 -58
- package/types/api/network/download.d.ts +34 -30
- package/types/api/network/mdns.d.ts +104 -91
- package/types/api/network/request.d.ts +83 -79
- package/types/api/network/udp.d.ts +20 -16
- package/types/api/network/upload.d.ts +60 -56
- package/types/api/network/websocket.d.ts +201 -194
- package/types/api/open-api/account.d.ts +18 -14
- package/types/api/open-api/address.d.ts +27 -23
- package/types/api/open-api/authorize.d.ts +30 -26
- package/types/api/open-api/card.d.ts +55 -51
- package/types/api/open-api/customer-service.d.ts +21 -17
- package/types/api/open-api/facial.d.ts +28 -24
- package/types/api/open-api/invoice.d.ts +38 -34
- package/types/api/open-api/login.d.ts +56 -52
- package/types/api/open-api/navigate.d.ts +79 -75
- package/types/api/open-api/payment.d.ts +34 -30
- package/types/api/open-api/settings.d.ts +49 -45
- package/types/api/open-api/soter.d.ts +92 -86
- package/types/api/open-api/subscribe-message.d.ts +24 -20
- package/types/api/open-api/user-info.d.ts +60 -57
- package/types/api/open-api/werun.d.ts +50 -46
- package/types/api/route/index.d.ts +122 -118
- package/types/api/share/index.d.ts +68 -64
- package/types/api/storage/background-fetch.d.ts +40 -35
- package/types/api/storage/index.d.ts +267 -262
- package/types/api/swan/index.d.ts +47 -42
- package/types/api/ui/animation.d.ts +21 -17
- package/types/api/ui/background.d.ts +38 -34
- package/types/api/ui/custom-component.d.ts +22 -18
- package/types/api/ui/fonts.d.ts +26 -21
- package/types/api/ui/interaction.d.ts +171 -122
- package/types/api/ui/keyboard.d.ts +59 -55
- package/types/api/ui/menu.d.ts +10 -6
- package/types/api/ui/navigation-bar.d.ts +67 -63
- package/types/api/ui/pull-down-refresh.d.ts +33 -29
- package/types/api/ui/scroll.d.ts +30 -26
- package/types/api/ui/sticky.d.ts +22 -19
- package/types/api/ui/tab-bar.d.ts +101 -97
- package/types/api/ui/window.d.ts +24 -18
- package/types/api/worker/index.d.ts +28 -24
- package/types/api/wxml/index.d.ts +42 -38
- package/types/compile.d.ts +1 -5
- package/types/global.d.ts +392 -0
- package/types/index.d.ts +12 -98
- package/types/taro.api.d.ts +94 -0
- package/types/taro.component.d.ts +10 -57
- package/types/taro.config.d.ts +24 -6
- package/types/taro.extend.d.ts +46 -75
- package/types/taro.hooks.d.ts +68 -67
- package/types/taro.lifecycle.d.ts +47 -28
- package/types/api/ad/index.ts +0 -6
- package/types/api/alipay/index.ts +0 -7
- package/types/api/index.d.ts +0 -352
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
2
4
|
namespace createAnimation {
|
|
3
5
|
interface Option {
|
|
4
6
|
/** 动画延迟时间,单位 ms */
|
|
@@ -27,28 +29,13 @@ declare namespace Taro {
|
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
/** 创建一个动画实例 animation。调用实例的方法来描述动画。最后通过动画实例的 export 方法导出动画数据传递给组件的 animation 属性。
|
|
31
|
-
* @supported weapp, h5
|
|
32
|
-
* @example
|
|
33
|
-
* ```tsx
|
|
34
|
-
* var animation = Taro.createAnimation({
|
|
35
|
-
* transformOrigin: "50% 50%",
|
|
36
|
-
* duration: 1000,
|
|
37
|
-
* timingFunction: "ease",
|
|
38
|
-
* delay: 0
|
|
39
|
-
* })
|
|
40
|
-
* ```
|
|
41
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/wx.createAnimation.html
|
|
42
|
-
*/
|
|
43
|
-
function createAnimation(option: createAnimation.Option): Animation
|
|
44
|
-
|
|
45
32
|
interface Animation {
|
|
46
33
|
/** 导出动画队列。**export 方法每次调用后会清掉之前的动画操作。**
|
|
47
34
|
* @supported weapp
|
|
48
35
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.export.html
|
|
49
36
|
*/
|
|
50
37
|
export(): {
|
|
51
|
-
actions:
|
|
38
|
+
actions: TaroGeneral.IAnyObject[]
|
|
52
39
|
}
|
|
53
40
|
/** 设置背景色
|
|
54
41
|
* @supported weapp
|
|
@@ -465,4 +452,21 @@ declare namespace Taro {
|
|
|
465
452
|
/** 起始和结束的滚动范围映射的时间长度,该时间可用于与关键帧动画里的时间 (duration) 相匹配,单位 ms */
|
|
466
453
|
timeRange: number
|
|
467
454
|
}
|
|
455
|
+
|
|
456
|
+
interface TaroStatic {
|
|
457
|
+
/** 创建一个动画实例 animation。调用实例的方法来描述动画。最后通过动画实例的 export 方法导出动画数据传递给组件的 animation 属性。
|
|
458
|
+
* @supported weapp, h5
|
|
459
|
+
* @example
|
|
460
|
+
* ```tsx
|
|
461
|
+
* var animation = Taro.createAnimation({
|
|
462
|
+
* transformOrigin: "50% 50%",
|
|
463
|
+
* duration: 1000,
|
|
464
|
+
* timingFunction: "ease",
|
|
465
|
+
* delay: 0
|
|
466
|
+
* })
|
|
467
|
+
* ```
|
|
468
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/wx.createAnimation.html
|
|
469
|
+
*/
|
|
470
|
+
createAnimation(option: createAnimation.Option): Animation
|
|
471
|
+
}
|
|
468
472
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
2
4
|
namespace setBackgroundTextStyle {
|
|
3
5
|
interface Option {
|
|
4
6
|
/** 下拉背景字体、loading 图的样式。
|
|
@@ -8,26 +10,14 @@ declare namespace Taro {
|
|
|
8
10
|
* - 'light': light 样式; */
|
|
9
11
|
textStyle: 'dark' | 'light'
|
|
10
12
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
11
|
-
complete?: (res:
|
|
13
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
12
14
|
/** 接口调用失败的回调函数 */
|
|
13
|
-
fail?: (res:
|
|
15
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
14
16
|
/** 接口调用成功的回调函数 */
|
|
15
|
-
success?: (res:
|
|
17
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
/** 动态设置下拉背景字体、loading 图的样式
|
|
20
|
-
* @supported weapp
|
|
21
|
-
* @example
|
|
22
|
-
* ```tsx
|
|
23
|
-
* Taro.setBackgroundTextStyle({
|
|
24
|
-
* textStyle: 'dark' // 下拉背景字体、loading 图的样式为dark
|
|
25
|
-
* })
|
|
26
|
-
* ```
|
|
27
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/background/wx.setBackgroundTextStyle.html
|
|
28
|
-
*/
|
|
29
|
-
function setBackgroundTextStyle(option: setBackgroundTextStyle.Option): Promise<General.CallbackResult>
|
|
30
|
-
|
|
31
21
|
namespace setBackgroundColor {
|
|
32
22
|
interface Option {
|
|
33
23
|
/** 窗口的背景色,必须为十六进制颜色值 */
|
|
@@ -37,27 +27,41 @@ declare namespace Taro {
|
|
|
37
27
|
/** 顶部窗口的背景色,必须为十六进制颜色值,仅 iOS 支持 */
|
|
38
28
|
backgroundColorTop?: string
|
|
39
29
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
40
|
-
complete?: (res:
|
|
30
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
41
31
|
/** 接口调用失败的回调函数 */
|
|
42
|
-
fail?: (res:
|
|
32
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
43
33
|
/** 接口调用成功的回调函数 */
|
|
44
|
-
success?: (res:
|
|
34
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
45
35
|
}
|
|
46
36
|
}
|
|
47
37
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
38
|
+
interface TaroStatic {
|
|
39
|
+
/** 动态设置下拉背景字体、loading 图的样式
|
|
40
|
+
* @supported weapp
|
|
41
|
+
* @example
|
|
42
|
+
* ```tsx
|
|
43
|
+
* Taro.setBackgroundTextStyle({
|
|
44
|
+
* textStyle: 'dark' // 下拉背景字体、loading 图的样式为dark
|
|
45
|
+
* })
|
|
46
|
+
* ```
|
|
47
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/background/wx.setBackgroundTextStyle.html
|
|
48
|
+
*/
|
|
49
|
+
setBackgroundTextStyle(option: setBackgroundTextStyle.Option): Promise<TaroGeneral.CallbackResult>
|
|
50
|
+
|
|
51
|
+
/** 动态设置窗口的背景色
|
|
52
|
+
* @supported weapp
|
|
53
|
+
* @example
|
|
54
|
+
* ```tsx
|
|
55
|
+
* Taro.setBackgroundColor({
|
|
56
|
+
* backgroundColor: '#ffffff', // 窗口的背景色为白色
|
|
57
|
+
* })
|
|
58
|
+
* Taro.setBackgroundColor({
|
|
59
|
+
* backgroundColorTop: '#ffffff', // 顶部窗口的背景色为白色
|
|
60
|
+
* backgroundColorBottom: '#ffffff', // 底部窗口的背景色为白色
|
|
61
|
+
* })
|
|
62
|
+
* ```
|
|
63
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/background/wx.setBackgroundColor.html
|
|
64
|
+
*/
|
|
65
|
+
setBackgroundColor(option: setBackgroundColor.Option): Promise<TaroGeneral.CallbackResult>
|
|
66
|
+
}
|
|
63
67
|
}
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
4
|
+
interface TaroStatic {
|
|
5
|
+
/** 延迟一部分操作到下一个时间片再执行。(类似于 setTimeout)
|
|
6
|
+
*
|
|
7
|
+
* **说明**
|
|
8
|
+
* 因为自定义组件中的 setData 和 triggerEvent 等接口本身是同步的操作,当这几个接口被连续调用时,都是在一个同步流程中执行完的,因此若逻辑不当可能会导致出错。
|
|
9
|
+
* 一个极端的案例:当父组件的 setData 引发了子组件的 triggerEvent,进而使得父组件又进行了一次 setData,期间有通过 wx:if 语句对子组件进行卸载,就有可能引发奇怪的错误,所以对于不需要在一个同步流程内完成的逻辑,可以使用此接口延迟到下一个时间片再执行。
|
|
10
|
+
* @supported weapp
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* this.setData({ number: 1 }) // 直接在当前同步流程中执行
|
|
14
|
+
* Taro.nextTick(() => {
|
|
15
|
+
* this.setData({ number: 3 }) // 在当前同步流程结束后,下一个时间片执行
|
|
16
|
+
* })
|
|
17
|
+
* this.setData({ number: 2 }) // 直接在当前同步流程中执行
|
|
18
|
+
* ```
|
|
19
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/custom-component/wx.nextTick.html
|
|
20
|
+
*/
|
|
21
|
+
nextTick(callback: (...args: any[]) => any): void
|
|
22
|
+
}
|
|
19
23
|
}
|
package/types/api/ui/fonts.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
2
4
|
namespace loadFontFace {
|
|
3
5
|
interface Option {
|
|
4
6
|
/** 是否全局生效
|
|
@@ -52,24 +54,27 @@ declare namespace Taro {
|
|
|
52
54
|
status: string
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
57
|
+
|
|
58
|
+
interface TaroStatic {
|
|
59
|
+
/** 动态加载网络字体。文件地址需为下载类型。iOS 仅支持 https 格式文件地址。
|
|
60
|
+
*
|
|
61
|
+
* 注意:
|
|
62
|
+
* 1. 字体文件返回的 contet-type 参考 [font](https://www.iana.org/assignments/media-types/media-types.xhtml#font),格式不正确时会解析失败。
|
|
63
|
+
* 2. 字体链接必须是https(ios不支持http)
|
|
64
|
+
* 3. 字体链接必须是同源下的,或开启了cors支持,小程序的域名是`servicewechat.com`
|
|
65
|
+
* 4. canvas等原生组件不支持使用接口添加的字体
|
|
66
|
+
* 5. 工具里提示 Faild to load font可以忽略
|
|
67
|
+
* @supported weapp
|
|
68
|
+
* @example
|
|
69
|
+
* ```tsx
|
|
70
|
+
* Taro.loadFontFace({
|
|
71
|
+
* family: 'Bitstream Vera Serif Bold',
|
|
72
|
+
* source: 'url("https://sungd.github.io/Pacifico.ttf")',
|
|
73
|
+
* success: console.log
|
|
74
|
+
* })
|
|
75
|
+
* ```
|
|
76
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/font/wx.loadFontFace.html
|
|
77
|
+
*/
|
|
78
|
+
loadFontFace(option: loadFontFace.Option): void
|
|
79
|
+
}
|
|
75
80
|
}
|
|
@@ -1,48 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
2
4
|
namespace showToast {
|
|
3
5
|
interface Option {
|
|
4
6
|
/** 提示的内容 */
|
|
5
7
|
title: string
|
|
6
8
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
7
|
-
complete?: (res:
|
|
9
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
8
10
|
/** 提示的延迟时间 */
|
|
9
11
|
duration?: number
|
|
10
12
|
/** 接口调用失败的回调函数 */
|
|
11
|
-
fail?: (res:
|
|
13
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
12
14
|
/** 图标
|
|
13
15
|
*
|
|
14
16
|
* 可选值:
|
|
15
17
|
* - 'success': 显示成功图标,此时 title 文本最多显示 7 个汉字长度;
|
|
18
|
+
* - 'error': 显示失败图标,此时 title 文本最多显示 7 个汉字长度;
|
|
16
19
|
* - 'loading': 显示加载图标,此时 title 文本最多显示 7 个汉字长度;
|
|
17
20
|
* - 'none': 不显示图标,此时 title 文本最多可显示两行 */
|
|
18
|
-
icon?: 'success' | 'loading' | 'none'
|
|
21
|
+
icon?: 'success' | 'error' | 'loading' | 'none'
|
|
19
22
|
/** 自定义图标的本地路径,image 的优先级高于 icon */
|
|
20
23
|
image?: string
|
|
21
24
|
/** 是否显示透明蒙层,防止触摸穿透 */
|
|
22
25
|
mask?: boolean
|
|
23
26
|
/** 接口调用成功的回调函数 */
|
|
24
|
-
success?: (res:
|
|
27
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
30
|
|
|
28
|
-
/** 显示消息提示框
|
|
29
|
-
*
|
|
30
|
-
* **注意**
|
|
31
|
-
* - Taro.showLoading 和 Taro.showToast 同时只能显示一个
|
|
32
|
-
* - Taro.showToast 应与 Taro.hideToast 配对使用
|
|
33
|
-
* @supported weapp, h5, rn
|
|
34
|
-
* @example
|
|
35
|
-
* ```tsx
|
|
36
|
-
* Taro.showToast({
|
|
37
|
-
* title: '成功',
|
|
38
|
-
* icon: 'success',
|
|
39
|
-
* duration: 2000
|
|
40
|
-
* })
|
|
41
|
-
* ```
|
|
42
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showToast.html
|
|
43
|
-
*/
|
|
44
|
-
function showToast(option?: showToast.Option): Promise<General.CallbackResult>
|
|
45
|
-
|
|
46
31
|
namespace showModal {
|
|
47
32
|
interface Option {
|
|
48
33
|
/** 取消按钮的文字颜色,必须是 16 进制格式的颜色字符串 */
|
|
@@ -50,7 +35,7 @@ declare namespace Taro {
|
|
|
50
35
|
/** 取消按钮的文字,最多 4 个字符 */
|
|
51
36
|
cancelText?: string
|
|
52
37
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
53
|
-
complete?: (res:
|
|
38
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
54
39
|
/** 确认按钮的文字颜色,必须是 16 进制格式的颜色字符串 */
|
|
55
40
|
confirmColor?: string
|
|
56
41
|
/** 确认按钮的文字,最多 4 个字符 */
|
|
@@ -58,7 +43,7 @@ declare namespace Taro {
|
|
|
58
43
|
/** 提示的内容 */
|
|
59
44
|
content?: string
|
|
60
45
|
/** 接口调用失败的回调函数 */
|
|
61
|
-
fail?: (res:
|
|
46
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
62
47
|
/** 是否显示取消按钮 */
|
|
63
48
|
showCancel?: boolean
|
|
64
49
|
/** 接口调用成功的回调函数 */
|
|
@@ -67,7 +52,7 @@ declare namespace Taro {
|
|
|
67
52
|
title?: string
|
|
68
53
|
}
|
|
69
54
|
|
|
70
|
-
interface SuccessCallbackResult extends
|
|
55
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
71
56
|
/** 为 true 时,表示用户点击了取消(用于 Android 系统区分点击蒙层关闭还是点击取消按钮关闭) */
|
|
72
57
|
cancel: boolean
|
|
73
58
|
/** 为 true 时,表示用户点击了确定按钮 */
|
|
@@ -77,77 +62,35 @@ declare namespace Taro {
|
|
|
77
62
|
}
|
|
78
63
|
}
|
|
79
64
|
|
|
80
|
-
/** 显示模态对话框
|
|
81
|
-
* **注意**
|
|
82
|
-
* - Android 6.7.2 以下版本,点击取消或蒙层时,回调 fail, errMsg 为 "fail cancel";
|
|
83
|
-
* - Android 6.7.2 及以上版本 和 iOS 点击蒙层不会关闭模态弹窗,所以尽量避免使用「取消」分支中实现业务逻辑
|
|
84
|
-
* @supported weapp, h5, rn
|
|
85
|
-
* @example
|
|
86
|
-
* ```tsx
|
|
87
|
-
* Taro.showModal({
|
|
88
|
-
* title: '提示',
|
|
89
|
-
* content: '这是一个模态弹窗',
|
|
90
|
-
* success: function (res) {
|
|
91
|
-
* if (res.confirm) {
|
|
92
|
-
* console.log('用户点击确定')
|
|
93
|
-
* } else if (res.cancel) {
|
|
94
|
-
* console.log('用户点击取消')
|
|
95
|
-
* }
|
|
96
|
-
* }
|
|
97
|
-
* })
|
|
98
|
-
* ```
|
|
99
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showModal.html
|
|
100
|
-
*/
|
|
101
|
-
function showModal(option?: showModal.Option): Promise<showModal.SuccessCallbackResult>
|
|
102
|
-
|
|
103
65
|
namespace showLoading {
|
|
104
66
|
interface Option {
|
|
105
67
|
/** 提示的内容 */
|
|
106
68
|
title: string
|
|
107
69
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
108
|
-
complete?: (res:
|
|
70
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
109
71
|
/** 接口调用失败的回调函数 */
|
|
110
|
-
fail?: (res:
|
|
72
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
111
73
|
/** 是否显示透明蒙层,防止触摸穿透 */
|
|
112
74
|
mask?: boolean
|
|
113
75
|
/** 接口调用成功的回调函数 */
|
|
114
|
-
success?: (res:
|
|
76
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
115
77
|
}
|
|
116
78
|
}
|
|
117
79
|
|
|
118
|
-
/** 显示 loading 提示框。需主动调用 Taro.hideLoading 才能关闭提示框
|
|
119
|
-
*
|
|
120
|
-
* **注意**
|
|
121
|
-
* - Taro.showLoading 和 Taro.showToast 同时只能显示一个
|
|
122
|
-
* - Taro.showLoading 应与 Taro.hideLoading 配对使用
|
|
123
|
-
* @supported weapp, h5, rn
|
|
124
|
-
* @example
|
|
125
|
-
* ```tsx
|
|
126
|
-
* Taro.showLoading({
|
|
127
|
-
* title: '加载中',
|
|
128
|
-
* })
|
|
129
|
-
* setTimeout(function () {
|
|
130
|
-
* Taro.hideLoading()
|
|
131
|
-
* }, 2000)
|
|
132
|
-
* ```
|
|
133
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showLoading.html
|
|
134
|
-
*/
|
|
135
|
-
function showLoading(option?: showLoading.Option): Promise<General.CallbackResult>
|
|
136
|
-
|
|
137
80
|
namespace showActionSheet {
|
|
138
81
|
interface Option {
|
|
139
82
|
/** 按钮的文字数组,数组长度最大为 6 */
|
|
140
83
|
itemList: string[]
|
|
141
84
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
142
|
-
complete?: (res:
|
|
85
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
143
86
|
/** 接口调用失败的回调函数 */
|
|
144
|
-
fail?: (res:
|
|
87
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
145
88
|
/** 按钮的文字颜色 */
|
|
146
89
|
itemColor?: string
|
|
147
90
|
/** 接口调用成功的回调函数 */
|
|
148
91
|
success?: (result: SuccessCallbackResult) => void
|
|
149
92
|
}
|
|
150
|
-
interface SuccessCallbackResult extends
|
|
93
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
151
94
|
/** 用户点击的按钮序号,从上到下的顺序,从0开始 */
|
|
152
95
|
tapIndex: number
|
|
153
96
|
/** 调用结果 */
|
|
@@ -155,68 +98,174 @@ declare namespace Taro {
|
|
|
155
98
|
}
|
|
156
99
|
}
|
|
157
100
|
|
|
158
|
-
/** 显示操作菜单
|
|
159
|
-
*
|
|
160
|
-
* **注意**
|
|
161
|
-
* - Android 6.7.2 以下版本,点击取消或蒙层时,回调 fail, errMsg 为 "fail cancel";
|
|
162
|
-
* - Android 6.7.2 及以上版本 和 iOS 点击蒙层不会关闭模态弹窗,所以尽量避免使用「取消」分支中实现业务逻辑
|
|
163
|
-
* @supported weapp, h5, rn
|
|
164
|
-
* @example
|
|
165
|
-
* ```tsx
|
|
166
|
-
* Taro.showActionSheet({
|
|
167
|
-
* itemList: ['A', 'B', 'C'],
|
|
168
|
-
* success: function (res) {
|
|
169
|
-
* console.log(res.tapIndex)
|
|
170
|
-
* },
|
|
171
|
-
* fail: function (res) {
|
|
172
|
-
* console.log(res.errMsg)
|
|
173
|
-
* }
|
|
174
|
-
* })
|
|
175
|
-
* ```
|
|
176
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showActionSheet.html
|
|
177
|
-
*/
|
|
178
|
-
function showActionSheet(option: showActionSheet.Option): Promise<showActionSheet.SuccessCallbackResult>
|
|
179
|
-
|
|
180
101
|
namespace hideToast {
|
|
181
102
|
interface Option {
|
|
182
103
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
183
|
-
complete?: (res:
|
|
104
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
184
105
|
/** 接口调用失败的回调函数 */
|
|
185
|
-
fail?: (res:
|
|
106
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
186
107
|
/** 接口调用成功的回调函数 */
|
|
187
|
-
success?: (res:
|
|
108
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
188
109
|
}
|
|
189
110
|
}
|
|
190
111
|
|
|
191
|
-
/** 隐藏消息提示框
|
|
192
|
-
* @supported weapp, h5, rn
|
|
193
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.hideToast.html
|
|
194
|
-
*/
|
|
195
|
-
function hideToast(option?: hideToast.Option): void
|
|
196
|
-
|
|
197
112
|
namespace hideLoading {
|
|
198
113
|
interface Option {
|
|
199
114
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
200
|
-
complete?: (res:
|
|
115
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
116
|
+
/** 接口调用失败的回调函数 */
|
|
117
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
118
|
+
/** 接口调用成功的回调函数 */
|
|
119
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
namespace enableAlertBeforeUnload {
|
|
124
|
+
interface Option {
|
|
125
|
+
/** 询问对话框内容 */
|
|
126
|
+
message: string
|
|
127
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
128
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
129
|
+
/** 接口调用失败的回调函数 */
|
|
130
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
131
|
+
/** 接口调用成功的回调函数 */
|
|
132
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
namespace disableAlertBeforeUnload {
|
|
137
|
+
interface Option {
|
|
138
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
139
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
201
140
|
/** 接口调用失败的回调函数 */
|
|
202
|
-
fail?: (res:
|
|
141
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
203
142
|
/** 接口调用成功的回调函数 */
|
|
204
|
-
success?: (res:
|
|
143
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
205
144
|
}
|
|
206
145
|
}
|
|
207
146
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
147
|
+
interface TaroStatic {
|
|
148
|
+
/** 显示消息提示框
|
|
149
|
+
*
|
|
150
|
+
* **注意**
|
|
151
|
+
* - Taro.showLoading 和 Taro.showToast 同时只能显示一个
|
|
152
|
+
* - Taro.showToast 应与 Taro.hideToast 配对使用
|
|
153
|
+
* @supported weapp, h5, rn
|
|
154
|
+
* @example
|
|
155
|
+
* ```tsx
|
|
156
|
+
* Taro.showToast({
|
|
157
|
+
* title: '成功',
|
|
158
|
+
* icon: 'success',
|
|
159
|
+
* duration: 2000
|
|
160
|
+
* })
|
|
161
|
+
* ```
|
|
162
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showToast.html
|
|
163
|
+
*/
|
|
164
|
+
showToast(option?: showToast.Option): Promise<TaroGeneral.CallbackResult>
|
|
165
|
+
|
|
166
|
+
/** 显示模态对话框
|
|
167
|
+
* **注意**
|
|
168
|
+
* - Android 6.7.2 以下版本,点击取消或蒙层时,回调 fail, errMsg 为 "fail cancel";
|
|
169
|
+
* - Android 6.7.2 及以上版本 和 iOS 点击蒙层不会关闭模态弹窗,所以尽量避免使用「取消」分支中实现业务逻辑
|
|
170
|
+
* @supported weapp, h5, rn
|
|
171
|
+
* @example
|
|
172
|
+
* ```tsx
|
|
173
|
+
* Taro.showModal({
|
|
174
|
+
* title: '提示',
|
|
175
|
+
* content: '这是一个模态弹窗',
|
|
176
|
+
* success: function (res) {
|
|
177
|
+
* if (res.confirm) {
|
|
178
|
+
* console.log('用户点击确定')
|
|
179
|
+
* } else if (res.cancel) {
|
|
180
|
+
* console.log('用户点击取消')
|
|
181
|
+
* }
|
|
182
|
+
* }
|
|
183
|
+
* })
|
|
184
|
+
* ```
|
|
185
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showModal.html
|
|
186
|
+
*/
|
|
187
|
+
showModal(option?: showModal.Option): Promise<showModal.SuccessCallbackResult>
|
|
188
|
+
|
|
189
|
+
/** 显示 loading 提示框。需主动调用 Taro.hideLoading 才能关闭提示框
|
|
190
|
+
*
|
|
191
|
+
* **注意**
|
|
192
|
+
* - Taro.showLoading 和 Taro.showToast 同时只能显示一个
|
|
193
|
+
* - Taro.showLoading 应与 Taro.hideLoading 配对使用
|
|
194
|
+
* @supported weapp, h5, rn
|
|
195
|
+
* @example
|
|
196
|
+
* ```tsx
|
|
197
|
+
* Taro.showLoading({
|
|
198
|
+
* title: '加载中',
|
|
199
|
+
* })
|
|
200
|
+
* setTimeout(function () {
|
|
201
|
+
* Taro.hideLoading()
|
|
202
|
+
* }, 2000)
|
|
203
|
+
* ```
|
|
204
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showLoading.html
|
|
205
|
+
*/
|
|
206
|
+
showLoading(option?: showLoading.Option): Promise<TaroGeneral.CallbackResult>
|
|
207
|
+
|
|
208
|
+
/** 显示操作菜单
|
|
209
|
+
*
|
|
210
|
+
* **注意**
|
|
211
|
+
* - Android 6.7.2 以下版本,点击取消或蒙层时,回调 fail, errMsg 为 "fail cancel";
|
|
212
|
+
* - Android 6.7.2 及以上版本 和 iOS 点击蒙层不会关闭模态弹窗,所以尽量避免使用「取消」分支中实现业务逻辑
|
|
213
|
+
* @supported weapp, h5, rn
|
|
214
|
+
* @example
|
|
215
|
+
* ```tsx
|
|
216
|
+
* Taro.showActionSheet({
|
|
217
|
+
* itemList: ['A', 'B', 'C'],
|
|
218
|
+
* success: function (res) {
|
|
219
|
+
* console.log(res.tapIndex)
|
|
220
|
+
* },
|
|
221
|
+
* fail: function (res) {
|
|
222
|
+
* console.log(res.errMsg)
|
|
223
|
+
* }
|
|
224
|
+
* })
|
|
225
|
+
* ```
|
|
226
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showActionSheet.html
|
|
227
|
+
*/
|
|
228
|
+
showActionSheet(option: showActionSheet.Option): Promise<showActionSheet.SuccessCallbackResult>
|
|
229
|
+
|
|
230
|
+
/** 隐藏消息提示框
|
|
231
|
+
* @supported weapp, h5, rn
|
|
232
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.hideToast.html
|
|
233
|
+
*/
|
|
234
|
+
hideToast(option?: hideToast.Option): void
|
|
235
|
+
|
|
236
|
+
/** 隐藏 loading 提示框
|
|
237
|
+
* @supported weapp, h5, rn
|
|
238
|
+
* @example
|
|
239
|
+
* ```tsx
|
|
240
|
+
* Taro.showLoading({
|
|
241
|
+
* title: '加载中',
|
|
242
|
+
* })
|
|
243
|
+
* setTimeout(function (){
|
|
244
|
+
* Taro.hideLoading()
|
|
245
|
+
* },2000)
|
|
246
|
+
* ```
|
|
247
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.hideLoading.html
|
|
248
|
+
*/
|
|
249
|
+
hideLoading(option?: hideLoading.Option): void /** 隐藏 loading 提示框
|
|
250
|
+
|
|
251
|
+
/** 开启小程序页面返回询问对话框
|
|
252
|
+
* @supported weapp
|
|
253
|
+
* @example
|
|
254
|
+
* ```tsx
|
|
255
|
+
* Taro.enableAlertBeforeUnload({
|
|
256
|
+
* success: function () {
|
|
257
|
+
* console.log('success')
|
|
258
|
+
* },
|
|
259
|
+
* })
|
|
260
|
+
* ```
|
|
261
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.enableAlertBeforeUnload.html
|
|
262
|
+
*/
|
|
263
|
+
enableAlertBeforeUnload(option: enableAlertBeforeUnload.Option): void
|
|
264
|
+
|
|
265
|
+
/** 关闭小程序页面返回询问对话框
|
|
266
|
+
* @supported weapp
|
|
267
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.disableAlertBeforeUnload.html
|
|
268
|
+
*/
|
|
269
|
+
disableAlertBeforeUnload(option?: disableAlertBeforeUnload.Option): void
|
|
270
|
+
}
|
|
222
271
|
}
|