@tarojs/taro 3.5.0-theta.1 → 3.5.1-aplha.1
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 +3 -3
- package/types/api/canvas/index.d.ts +1 -1
- package/types/api/device/vibrate.d.ts +4 -0
- package/types/api/framework/index.d.ts +4 -3
- package/types/api/location/index.d.ts +36 -0
- package/types/api/network/download.d.ts +22 -3
- package/types/api/network/upload.d.ts +14 -3
- package/types/compile.d.ts +10 -0
- package/types/taro.component.d.ts +11 -57
- package/types/taro.config.d.ts +13 -0
- package/types/taro.extend.d.ts +24 -20
- package/types/taro.hooks.d.ts +22 -4
- package/types/taro.lifecycle.d.ts +21 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/taro",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.1-aplha.1",
|
|
4
4
|
"description": "Taro framework",
|
|
5
5
|
"homepage": "https://github.com/nervjs/taro/tree/master/packages/taro#readme",
|
|
6
6
|
"main": "index.js",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"author": "O2Team",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@tarojs/api": "3.5.
|
|
25
|
-
"@tarojs/runtime": "3.5.
|
|
24
|
+
"@tarojs/api": "3.5.1-aplha.1",
|
|
25
|
+
"@tarojs/runtime": "3.5.1-aplha.1"
|
|
26
26
|
},
|
|
27
27
|
"peerDependenciesMeta": {
|
|
28
28
|
"@types/react": {
|
|
@@ -4,7 +4,7 @@ declare module '../../index' {
|
|
|
4
4
|
namespace canvasToTempFilePath {
|
|
5
5
|
interface Option {
|
|
6
6
|
/** 画布标识,传入 [canvas](/docs/components/canvas) 组件实例 (canvas type="2d" 时使用该属性)。 */
|
|
7
|
-
canvas?:
|
|
7
|
+
canvas?: Canvas
|
|
8
8
|
/** 画布标识,传入 [canvas](/docs/components/canvas) 组件的 canvas-id */
|
|
9
9
|
canvasId?: string
|
|
10
10
|
/** 图片的质量,目前仅对 jpg 有效。取值范围为 (0, 1],不在范围内时当作 1.0 处理。 */
|
|
@@ -3,6 +3,8 @@ import Taro from '../../index'
|
|
|
3
3
|
declare module '../../index' {
|
|
4
4
|
namespace vibrateShort {
|
|
5
5
|
interface Option {
|
|
6
|
+
/** 震动强度类型,有效值为:heavy、medium、light */
|
|
7
|
+
type: 'heavy' | 'medium' | 'light'
|
|
6
8
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
7
9
|
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
8
10
|
/** 接口调用失败的回调函数 */
|
|
@@ -25,6 +27,8 @@ declare module '../../index' {
|
|
|
25
27
|
|
|
26
28
|
interface TaroStatic {
|
|
27
29
|
/** 使手机发生较短时间的振动(15 ms)。仅在 iPhone `7 / 7 Plus` 以上及 Android 机型生效
|
|
30
|
+
* @h5 不支持 type 参数
|
|
31
|
+
* @rn 不支持 type 参数
|
|
28
32
|
* @supported weapp, h5, rn, tt
|
|
29
33
|
* @example
|
|
30
34
|
* ```tsx
|
|
@@ -3,10 +3,11 @@ import Taro from '../../index'
|
|
|
3
3
|
declare module '../../index' {
|
|
4
4
|
/** 注册小程序中的一个页面。接受一个 `Object` 类型参数,其指定页面的初始数据、生命周期回调、事件处理函数等。 */
|
|
5
5
|
interface Page {
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
6
|
+
/** 当前页面的路径
|
|
7
|
+
* @note 推荐使用 Taro.getCurrentInstance().router?.path 方法
|
|
8
8
|
*/
|
|
9
|
-
route
|
|
9
|
+
route?: string
|
|
10
|
+
__route__?: string
|
|
10
11
|
/** @ignore */
|
|
11
12
|
[k: string]: any
|
|
12
13
|
}
|
|
@@ -188,6 +188,26 @@ declare module '../../index' {
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
+
namespace getFuzzyLocation {
|
|
192
|
+
interface Option {
|
|
193
|
+
/** wgs84 返回 gps 坐标,gcj02 返回可用于 Taro.openLocation 的坐标 */
|
|
194
|
+
type?: 'wgs84' | 'gcj02'
|
|
195
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
196
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
197
|
+
/** 接口调用失败的回调函数 */
|
|
198
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
199
|
+
/** 接口调用成功的回调函数 */
|
|
200
|
+
success?: (result: SuccessCallbackResult) => void
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
204
|
+
/** 纬度,范围为 -90~90,负数表示南纬 */
|
|
205
|
+
latitude: string
|
|
206
|
+
/** 经度,范围为 -180~180,负数表示西经 */
|
|
207
|
+
longitude: string
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
191
211
|
interface TaroStatic {
|
|
192
212
|
/** 关闭监听实时位置变化,前后台都停止消息接收
|
|
193
213
|
* @supported weapp, rn, tt
|
|
@@ -329,5 +349,21 @@ declare module '../../index' {
|
|
|
329
349
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.chooseLocation.html
|
|
330
350
|
*/
|
|
331
351
|
chooseLocation(option: chooseLocation.Option): Promise<chooseLocation.SuccessCallbackResult>
|
|
352
|
+
|
|
353
|
+
/** 获取当前的模糊地理位置
|
|
354
|
+
* @supported weapp
|
|
355
|
+
* @example
|
|
356
|
+
* ```tsx
|
|
357
|
+
* Taro.getFuzzyLocation({
|
|
358
|
+
* type: 'wgs84',
|
|
359
|
+
* success (res) {
|
|
360
|
+
* const latitude = res.latitude
|
|
361
|
+
* const longitude = res.longitude
|
|
362
|
+
* },
|
|
363
|
+
* })
|
|
364
|
+
* ```
|
|
365
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.getFuzzyLocation.html
|
|
366
|
+
*/
|
|
367
|
+
getFuzzyLocation(option: getFuzzyLocation.Option): Promise<getFuzzyLocation.SuccessCallbackResult>
|
|
332
368
|
}
|
|
333
369
|
}
|
|
@@ -26,6 +26,26 @@ declare module '../../index' {
|
|
|
26
26
|
tempFilePath: string
|
|
27
27
|
/** 调用结果 */
|
|
28
28
|
errMsg: string
|
|
29
|
+
/**
|
|
30
|
+
* 开发者服务器返回的 HTTP Response Header
|
|
31
|
+
* @supported weapp
|
|
32
|
+
* @weapp 非官方文档标注属性
|
|
33
|
+
*/
|
|
34
|
+
header?: TaroGeneral.IAnyObject
|
|
35
|
+
/**
|
|
36
|
+
* 数据长度,单位 Byte
|
|
37
|
+
* @supported weapp
|
|
38
|
+
* @weapp 非官方文档标注属性
|
|
39
|
+
*/
|
|
40
|
+
dataLength?: number
|
|
41
|
+
/**
|
|
42
|
+
* cookies
|
|
43
|
+
* @supported weapp
|
|
44
|
+
* @weapp 非官方文档标注属性
|
|
45
|
+
*/
|
|
46
|
+
cookies?: string[]
|
|
47
|
+
/** 网络请求过程中一些调试信息 */
|
|
48
|
+
profile?: TaroGeneral.IAnyObject
|
|
29
49
|
}
|
|
30
50
|
}
|
|
31
51
|
|
|
@@ -59,10 +79,9 @@ declare module '../../index' {
|
|
|
59
79
|
totalBytesWritten: number
|
|
60
80
|
}
|
|
61
81
|
|
|
62
|
-
type DownloadTaskPromise = Promise<
|
|
82
|
+
type DownloadTaskPromise = Promise<downloadFile.FileSuccessCallbackResult> & DownloadTask & {
|
|
63
83
|
headersReceive: DownloadTask['onHeadersReceived'],
|
|
64
|
-
progress: DownloadTask['onProgressUpdate']
|
|
65
|
-
abort: DownloadTask['abort']
|
|
84
|
+
progress: DownloadTask['onProgressUpdate']
|
|
66
85
|
}
|
|
67
86
|
}
|
|
68
87
|
|
|
@@ -35,6 +35,18 @@ declare module '../../index' {
|
|
|
35
35
|
statusCode: number
|
|
36
36
|
/** 调用结果 */
|
|
37
37
|
errMsg: string
|
|
38
|
+
/**
|
|
39
|
+
* 开发者服务器返回的 HTTP Response Header
|
|
40
|
+
* @supported weapp
|
|
41
|
+
* @weapp 非官方文档标注属性
|
|
42
|
+
*/
|
|
43
|
+
header?: TaroGeneral.IAnyObject
|
|
44
|
+
/**
|
|
45
|
+
* cookies
|
|
46
|
+
* @supported weapp
|
|
47
|
+
* @weapp 非官方文档标注属性
|
|
48
|
+
*/
|
|
49
|
+
cookies?: string[]
|
|
38
50
|
}
|
|
39
51
|
}
|
|
40
52
|
|
|
@@ -68,10 +80,9 @@ declare module '../../index' {
|
|
|
68
80
|
totalBytesSent: number
|
|
69
81
|
}
|
|
70
82
|
|
|
71
|
-
type UploadTaskPromise = Promise<
|
|
83
|
+
type UploadTaskPromise = Promise<uploadFile.SuccessCallbackResult> & UploadTask & {
|
|
72
84
|
headersReceive: UploadTask['onHeadersReceived'],
|
|
73
|
-
progress: UploadTask['onProgressUpdate']
|
|
74
|
-
abort: UploadTask['abort']
|
|
85
|
+
progress: UploadTask['onProgressUpdate']
|
|
75
86
|
}
|
|
76
87
|
}
|
|
77
88
|
|
package/types/compile.d.ts
CHANGED
|
@@ -388,6 +388,8 @@ interface ILogger {
|
|
|
388
388
|
}
|
|
389
389
|
|
|
390
390
|
export interface IProjectBaseConfig {
|
|
391
|
+
isWatch?: boolean
|
|
392
|
+
port?: number
|
|
391
393
|
projectName?: string
|
|
392
394
|
date?: string
|
|
393
395
|
designWidth?: number
|
|
@@ -410,9 +412,17 @@ export interface IProjectBaseConfig {
|
|
|
410
412
|
presets?: PluginItem[]
|
|
411
413
|
baseLevel?: number
|
|
412
414
|
framework?: string
|
|
415
|
+
frameworkExts?: string[]
|
|
413
416
|
compiler?: Compiler
|
|
414
417
|
cache?: ICache
|
|
415
418
|
logger?: ILogger
|
|
419
|
+
enableSourceMap?: boolean
|
|
420
|
+
/** hooks */
|
|
421
|
+
modifyWebpackChain?: HookModifyWebpackChain
|
|
422
|
+
modifyMiniConfigs?: (configMap) => Promise<any>
|
|
423
|
+
modifyBuildAssets?: (assets, plugin?) => Promise<any>
|
|
424
|
+
onWebpackChainReady?: (webpackChain: Chain) => Promise<any>
|
|
425
|
+
onBuildFinish?: (res: { error, stats, isWatch }) => Promise<any>
|
|
416
426
|
}
|
|
417
427
|
|
|
418
428
|
export interface IProjectConfig extends IProjectBaseConfig {
|
|
@@ -4,35 +4,6 @@ import Vue from 'vue'
|
|
|
4
4
|
import Taro, { Config } from './index'
|
|
5
5
|
|
|
6
6
|
declare module './index' {
|
|
7
|
-
// Components
|
|
8
|
-
interface ComponentLifecycle<P, S, SS = any> extends NewLifecycle<P, S, SS> {
|
|
9
|
-
componentWillMount?(): void
|
|
10
|
-
componentDidMount?(): void
|
|
11
|
-
componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void
|
|
12
|
-
shouldComponentUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): boolean
|
|
13
|
-
componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): void
|
|
14
|
-
componentWillUnmount?(): void
|
|
15
|
-
componentDidShow?(): void
|
|
16
|
-
componentDidHide?(): void
|
|
17
|
-
componentDidCatchError?(err: string): void
|
|
18
|
-
componentDidNotFound?(obj: PageNotFoundObject): void
|
|
19
|
-
onPullDownRefresh?(): void
|
|
20
|
-
onReachBottom?(): void
|
|
21
|
-
onPageScroll?(obj: PageScrollObject): void
|
|
22
|
-
onShareAppMessage?(obj: ShareAppMessageObject): ShareAppMessageReturn
|
|
23
|
-
onTabItemTap?(obj: TabItemTapObject): void
|
|
24
|
-
onResize?(obj: PageResizeObject): void
|
|
25
|
-
}
|
|
26
|
-
interface ComponentOptions {
|
|
27
|
-
addGlobalClass?: boolean
|
|
28
|
-
styleIsolation?: 'isolated' | 'apply-shared' | 'shared'
|
|
29
|
-
}
|
|
30
|
-
interface ComponentClass<P = {}, S = any> extends StaticLifecycle<P, S> {
|
|
31
|
-
new (...args: any[]): Component<P, {}>
|
|
32
|
-
propTypes?: any // TODO: Use prop-types type definition.
|
|
33
|
-
defaultProps?: Partial<P>
|
|
34
|
-
displayName?: string
|
|
35
|
-
}
|
|
36
7
|
// ref: packages/taro-runtime/src/current.ts
|
|
37
8
|
interface RouterInfo<TParams extends Partial<Record<string, string>> = Partial<Record<string, string>>> {
|
|
38
9
|
/** 路由参数 */
|
|
@@ -49,23 +20,6 @@ declare module './index' {
|
|
|
49
20
|
scene: number | undefined
|
|
50
21
|
exitState?: any
|
|
51
22
|
}
|
|
52
|
-
interface Component<P = {}, S = {}, SS = any> extends ComponentLifecycle<P, S, SS> {
|
|
53
|
-
$scope?: any
|
|
54
|
-
}
|
|
55
|
-
type PropsWithChildren<P> = P & { children?: React.ReactNode }
|
|
56
|
-
interface FunctionComponent<P = {}> {
|
|
57
|
-
(props: PropsWithChildren<P>, context?: any): React.ReactElement | null
|
|
58
|
-
propTypes?: any // TODO: Use prop-types type definition.
|
|
59
|
-
defaultProps?: Partial<P>
|
|
60
|
-
config?: Config
|
|
61
|
-
options?: ComponentOptions
|
|
62
|
-
externalClasses?: string[]
|
|
63
|
-
}
|
|
64
|
-
type FC<P = {}> = FunctionComponent<P>
|
|
65
|
-
interface StatelessFunctionComponent {
|
|
66
|
-
(): JSX.Element
|
|
67
|
-
}
|
|
68
|
-
type SFC = StatelessFunctionComponent
|
|
69
23
|
|
|
70
24
|
interface Show {
|
|
71
25
|
componentDidShow?(): void
|
|
@@ -74,10 +28,10 @@ declare module './index' {
|
|
|
74
28
|
onHide?(): void
|
|
75
29
|
}
|
|
76
30
|
interface AppInstance extends Show {
|
|
77
|
-
mount(component: React.Component | Vue.ComponentOptions<Vue>, id: string, cb: () => void): void
|
|
31
|
+
mount(component: React.Component | Vue.ComponentOptions<Vue>, id: string, cb: (...args: any[]) => void): void
|
|
78
32
|
componentDidShow?(options?: Record<string, unknown>): void
|
|
79
33
|
onShow?(options?: Record<string, unknown>): void
|
|
80
|
-
unmount(id: string, cb
|
|
34
|
+
unmount(id: string, cb?: () => void): void
|
|
81
35
|
}
|
|
82
36
|
type Target = Record<string, unknown> & { dataset: Record<string, unknown>; id: string }
|
|
83
37
|
interface MpEvent {
|
|
@@ -87,18 +41,18 @@ declare module './index' {
|
|
|
87
41
|
currentTarget: Target
|
|
88
42
|
}
|
|
89
43
|
interface PageLifeCycle extends Show {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
onPageScroll?(obj: { scrollTop: number }): void
|
|
93
|
-
onShareAppMessage?(obj: { from: string; target?: any; webViewUrl: string }): void
|
|
94
|
-
onResize?(options: unknown): void
|
|
95
|
-
onTabItemTap?(obj: { index: string; pagePath: string; text: string }): void
|
|
96
|
-
onTitleClick?(): void
|
|
44
|
+
eh?(event: MpEvent): void
|
|
45
|
+
onLoad(options: Record<string, unknown>): void
|
|
97
46
|
onOptionMenuClick?(): void
|
|
47
|
+
onPageScroll?(opt: PageScrollObject): void
|
|
98
48
|
onPopMenuClick?(): void
|
|
49
|
+
onPullDownRefresh?(): void
|
|
99
50
|
onPullIntercept?(): void
|
|
100
|
-
|
|
101
|
-
|
|
51
|
+
onReachBottom?(): void
|
|
52
|
+
onResize?(opt: PageResizeObject): void
|
|
53
|
+
onShareAppMessage?(opt: ShareAppMessageObject): ShareAppMessageReturn
|
|
54
|
+
onTabItemTap?(opt: TabItemTapObject): void
|
|
55
|
+
onTitleClick?(): void
|
|
102
56
|
onUnload(): void
|
|
103
57
|
}
|
|
104
58
|
interface ComponentInstance<
|
package/types/taro.config.d.ts
CHANGED
|
@@ -271,6 +271,19 @@ declare module './index' {
|
|
|
271
271
|
* @since 微信客户端 6.7.2 及以上版本支持
|
|
272
272
|
*/
|
|
273
273
|
requiredBackgroundModes?: ('audio' | 'location')[]
|
|
274
|
+
/** 申明需要使用的地理位置相关接口,类型为数组。目前支持以下项目:
|
|
275
|
+
* 自 2022 年 7 月 14 日后发布的小程序,使用以下8个地理位置相关接口时,需要声明该字段,否则将无法正常使用。2022 年 7 月 14 日前发布的小程序不受影响。
|
|
276
|
+
* - getFuzzyLocation: 获取模糊地理位置
|
|
277
|
+
* - getLocation: 获取精确地理位置
|
|
278
|
+
* - onLocationChange: 监听试试地理位置变化事件
|
|
279
|
+
* - startLocationUpdate: 接收位置消息(前台)
|
|
280
|
+
* - startLocationUpdateBackground: 接收位置消息(前后台)
|
|
281
|
+
* - chooseLocation: 打开地图选择位置
|
|
282
|
+
* - choosePoi: 打开 POI 列表选择位置
|
|
283
|
+
* - chooseAddress: 获取用户地址信息
|
|
284
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#requiredPrivateInfos
|
|
285
|
+
*/
|
|
286
|
+
requiredPrivateInfos?: ('getFuzzyLocation' | 'getLocation' | 'onLocationChange' | 'startLocationUpdate' | 'startLocationUpdateBackground' | 'chooseLocation' | 'choosePoi' | 'chooseAddress')[]
|
|
274
287
|
/** 使用到的插件
|
|
275
288
|
* @since 1.9.6
|
|
276
289
|
*/
|
package/types/taro.extend.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
|
|
3
|
-
import Taro
|
|
3
|
+
import Taro from './index'
|
|
4
4
|
|
|
5
5
|
declare module './index' {
|
|
6
6
|
type MessageType = 'info' | 'success' | 'error' | 'warning'
|
|
@@ -11,7 +11,7 @@ declare module './index' {
|
|
|
11
11
|
duration?: number
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
interface RequestParams<T> extends request.Option<T, any> {
|
|
14
|
+
interface RequestParams<T=any> extends request.Option<T, any> {
|
|
15
15
|
[propName: string]: any
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -49,36 +49,41 @@ declare module './index' {
|
|
|
49
49
|
new (): TaroGeneral.Events
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
/** 事件中心
|
|
53
|
+
* @supported global
|
|
54
|
+
*/
|
|
53
55
|
eventCenter: TaroGeneral.Events
|
|
54
56
|
|
|
55
57
|
ENV_TYPE: TARO_ENV_TYPE
|
|
56
58
|
|
|
59
|
+
/** 获取环境变量
|
|
60
|
+
* @supported global
|
|
61
|
+
*/
|
|
57
62
|
getEnv(): TaroGeneral.ENV_TYPE
|
|
58
63
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
internal_safe_get(...arg: any[]): any
|
|
63
|
-
|
|
64
|
-
atMessage(options: AtMessageOptions): void
|
|
65
|
-
|
|
64
|
+
/** 尺寸转换
|
|
65
|
+
* @supported global
|
|
66
|
+
*/
|
|
66
67
|
pxTransform(size: number, designWidth?: number): string
|
|
68
|
+
|
|
69
|
+
/** 尺寸转换初始化
|
|
70
|
+
* @supported global
|
|
71
|
+
*/
|
|
67
72
|
initPxTransform(config: { designWidth: number; deviceRatio: TaroGeneral.TDeviceRatio }): void
|
|
68
73
|
|
|
69
|
-
/**
|
|
70
|
-
*
|
|
74
|
+
/** 小程序引用插件 JS 接口
|
|
75
|
+
* @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp
|
|
71
76
|
*/
|
|
72
77
|
requirePlugin(pluginName: string): any
|
|
73
78
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
/** 获取当前页面实例
|
|
80
|
+
* @supported global
|
|
81
|
+
*/
|
|
78
82
|
getCurrentInstance(): Current
|
|
83
|
+
Current: Current
|
|
79
84
|
|
|
80
|
-
/**
|
|
81
|
-
* @
|
|
85
|
+
/** Vue3 插件,用于设置 `getApp()` 中的全局变量
|
|
86
|
+
* @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp
|
|
82
87
|
* @example
|
|
83
88
|
* ```js
|
|
84
89
|
* // 使用插件
|
|
@@ -92,9 +97,8 @@ declare module './index' {
|
|
|
92
97
|
*/
|
|
93
98
|
setGlobalDataPlugin: SetGlobalDataPlugin
|
|
94
99
|
|
|
95
|
-
/**
|
|
100
|
+
/** 获取自定义 TabBar 对应的 React 或 Vue 组件实例
|
|
96
101
|
* @supported weapp
|
|
97
|
-
* @desc 获取自定义 TabBar 对应的 React 或 Vue 组件实例
|
|
98
102
|
* @param page 小程序页面对象,可以通过 Taro.getCurrentInstance().page 获取
|
|
99
103
|
*/
|
|
100
104
|
getTabBar<T>(page: Current['page']): T | undefined
|
package/types/taro.hooks.d.ts
CHANGED
|
@@ -4,57 +4,67 @@ declare module './index' {
|
|
|
4
4
|
interface TaroStatic {
|
|
5
5
|
/**
|
|
6
6
|
* 页面展示时的回调。
|
|
7
|
+
* @supported global
|
|
7
8
|
*/
|
|
8
9
|
useDidShow(callback: () => void): void
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* 页面隐藏时的回调。
|
|
13
|
+
* @supported global
|
|
12
14
|
*/
|
|
13
15
|
useDidHide(callback: () => void): void
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* 下拉刷新时的回调。
|
|
19
|
+
* @supported global
|
|
17
20
|
*/
|
|
18
21
|
usePullDownRefresh(callback: () => void): void
|
|
19
22
|
|
|
20
23
|
/**
|
|
21
24
|
* 上拉触底时的回调。
|
|
25
|
+
* @supported global
|
|
22
26
|
*/
|
|
23
27
|
useReachBottom(callback: () => void): void
|
|
24
28
|
|
|
25
29
|
/**
|
|
26
30
|
* 页面滚动时的回调。
|
|
31
|
+
* @supported global
|
|
27
32
|
*/
|
|
28
33
|
usePageScroll(callback: (payload: PageScrollObject) => void): void
|
|
29
34
|
|
|
30
35
|
/**
|
|
31
36
|
* 页面尺寸改变时的回调。
|
|
37
|
+
* @supported global
|
|
32
38
|
*/
|
|
33
39
|
useResize(callback: (payload: PageResizeObject) => void): void
|
|
34
40
|
|
|
35
41
|
/**
|
|
36
42
|
* 页面转发时的回调。
|
|
43
|
+
* @supported weapp
|
|
37
44
|
*/
|
|
38
45
|
useShareAppMessage(callback: (payload: ShareAppMessageObject) => ShareAppMessageReturn): void
|
|
39
46
|
|
|
40
47
|
/**
|
|
41
48
|
* 当前是 tab 页时,tab 被点击时的回调。
|
|
49
|
+
* @supported weapp, rn
|
|
42
50
|
*/
|
|
43
51
|
useTabItemTap(callback: (payload: TabItemTapObject) => void): void
|
|
44
52
|
|
|
45
53
|
/**
|
|
46
54
|
* 用户点击右上角菜单“收藏”按钮时的回调。
|
|
55
|
+
* @supported weapp
|
|
47
56
|
*/
|
|
48
57
|
useAddToFavorites(callback: (payload: AddToFavoritesObject) => AddToFavoritesReturnObject): void
|
|
49
58
|
|
|
50
59
|
/**
|
|
51
60
|
* 用户点击右上角菜单“分享到朋友圈”按钮时的回调。
|
|
61
|
+
* @supported weapp
|
|
52
62
|
*/
|
|
53
63
|
useShareTimeline(callback: () => ShareTimelineReturnObject): void
|
|
54
64
|
|
|
55
65
|
/**
|
|
56
66
|
* 页面销毁前保留状态回调
|
|
57
|
-
*
|
|
67
|
+
* @supported weapp
|
|
58
68
|
*/
|
|
59
69
|
useSaveExitState(callback: () => {
|
|
60
70
|
data: Record<any, any>
|
|
@@ -63,55 +73,63 @@ declare module './index' {
|
|
|
63
73
|
|
|
64
74
|
/**
|
|
65
75
|
* 小程序初始化完成时的回调。
|
|
76
|
+
* @supported weapp, h5
|
|
66
77
|
*/
|
|
67
78
|
useLaunch(callback: (options: getLaunchOptionsSync.LaunchOptions) => void): void
|
|
68
79
|
|
|
69
80
|
/**
|
|
70
81
|
* 小程序发生脚本错误或 API 调用报错时触发的回调。
|
|
82
|
+
* @supported weapp, h5
|
|
71
83
|
*/
|
|
72
84
|
useError(callback: (error: string) => void): void
|
|
73
85
|
|
|
74
86
|
/**
|
|
75
87
|
* 小程序要打开的页面不存在时触发的回调。
|
|
88
|
+
* @supported weapp, h5
|
|
89
|
+
* @h5 多页面模式不支持该方法
|
|
76
90
|
*/
|
|
77
91
|
usePageNotFound(callback: (res: { path: string, query: Record<any, any>, isEntryPage: boolean, [key: string]: any }) => void): void
|
|
78
92
|
|
|
79
93
|
/**
|
|
80
94
|
* 页面加载完成时的回调。
|
|
95
|
+
* @supported weapp, h5
|
|
81
96
|
*/
|
|
82
97
|
useLoad(callback: () => void): void
|
|
83
98
|
|
|
84
99
|
/**
|
|
85
100
|
* 页面卸载时的回调。
|
|
101
|
+
* @supported weapp, h5
|
|
86
102
|
*/
|
|
87
103
|
useUnload(callback: () => void): void
|
|
88
104
|
|
|
89
105
|
/**
|
|
90
106
|
* 页面初次渲染完成的回调。
|
|
91
107
|
* 此时页面已经准备妥当,可以和视图层进行交互。
|
|
108
|
+
* @supported weapp, h5
|
|
92
109
|
*/
|
|
93
110
|
useReady(callback: () => void): void
|
|
94
111
|
|
|
95
112
|
/**
|
|
96
113
|
* 获取当前路由参数。
|
|
114
|
+
* @supported global
|
|
97
115
|
*/
|
|
98
116
|
useRouter<TParams extends Partial<Record<string, string>> = Partial<Record<string, string>>>(dynamic?: boolean): RouterInfo<TParams>
|
|
99
117
|
|
|
100
118
|
/**
|
|
101
119
|
* 导航栏的标题被点击时的回调。
|
|
102
|
-
*
|
|
120
|
+
* @supported alipay
|
|
103
121
|
*/
|
|
104
122
|
useTitleClick(callback: () => void): void
|
|
105
123
|
|
|
106
124
|
/**
|
|
107
125
|
* 导航栏的额外图标被点击时的回调。
|
|
108
|
-
*
|
|
126
|
+
* @supported alipay
|
|
109
127
|
*/
|
|
110
128
|
useOptionMenuClick(callback: () => void): void
|
|
111
129
|
|
|
112
130
|
/**
|
|
113
131
|
* 下拉中断时的回调。
|
|
114
|
-
*
|
|
132
|
+
* @supported alipay, h5
|
|
115
133
|
*/
|
|
116
134
|
usePullIntercept(callback: () => void): void
|
|
117
135
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import Taro from './index'
|
|
2
2
|
|
|
3
3
|
type TaroGetDerivedStateFromProps<P, S> =
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
(nextProps: Readonly<P>, prevState: S) => Partial<S> | null
|
|
4
|
+
/**
|
|
5
|
+
* Returns an update to a component's state based on its new props and old state.
|
|
6
|
+
*
|
|
7
|
+
* Note: its presence prevents any of the deprecated lifecycle methods from being invoked
|
|
8
|
+
*/
|
|
9
|
+
(nextProps: Readonly<P>, prevState: S) => Partial<S> | null
|
|
10
10
|
|
|
11
11
|
interface TaroStaticLifecycle<P, S> {
|
|
12
|
-
getDerivedStateFromProps?: TaroGetDerivedStateFromProps<P, S
|
|
12
|
+
getDerivedStateFromProps?: TaroGetDerivedStateFromProps<P, S>
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
interface TaroNewLifecycle<P, S, SS> {
|
|
@@ -21,13 +21,13 @@ interface TaroNewLifecycle<P, S, SS> {
|
|
|
21
21
|
* Note: the presence of getSnapshotBeforeUpdate prevents any of the deprecated
|
|
22
22
|
* lifecycle events from running.
|
|
23
23
|
*/
|
|
24
|
-
getSnapshotBeforeUpdate?(prevProps: Readonly<P>, prevState: Readonly<S>): SS | null
|
|
24
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<P>, prevState: Readonly<S>): SS | null
|
|
25
25
|
/**
|
|
26
26
|
* Called immediately after updating occurs. Not called for the initial render.
|
|
27
27
|
*
|
|
28
28
|
* The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null.
|
|
29
29
|
*/
|
|
30
|
-
componentDidUpdate?(prevProps: Readonly<P>, prevState: Readonly<S>, snapshot?: SS): void
|
|
30
|
+
componentDidUpdate?(prevProps: Readonly<P>, prevState: Readonly<S>, snapshot?: SS): void
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
declare module './index' {
|
|
@@ -165,11 +165,18 @@ declare module './index' {
|
|
|
165
165
|
imageUrl?: string
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
interface ComponentLifecycle<P, S, SS = any> extends TaroNewLifecycle<P, S, SS> {
|
|
169
|
+
componentWillMount?(): void
|
|
170
|
+
componentDidMount?(): void
|
|
171
|
+
componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void
|
|
172
|
+
shouldComponentUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): boolean
|
|
173
|
+
componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): void
|
|
174
|
+
componentWillUnmount?(): void
|
|
175
|
+
componentDidCatch?(err: string): void
|
|
176
|
+
componentDidShow?(): void
|
|
177
|
+
componentDidHide?(): void
|
|
178
|
+
componentDidNotFound?(opt: PageNotFoundObject): void
|
|
179
|
+
}
|
|
173
180
|
|
|
174
181
|
interface TaroStatic {
|
|
175
182
|
PageNotFoundObject: PageNotFoundObject
|