UNPKG

3.54 kBTypeScriptView Raw
1import { ComponentType } from 'react'
2import { StandardProps, CommonEventFunction } from './common'
3
4interface NavigatorProps extends StandardProps {
5 /** 在哪个目标上发生跳转,默认当前小程序
6 * @default "self"
7 * @supported weapp, swan
8 */
9 target?: keyof NavigatorProps.Target
10
11 /** 当前小程序内的跳转链接
12 * @supported weapp, swan, alipay, tt
13 */
14 url?: string
15
16 /** 跳转方式
17 * @default "navigate"
18 * @supported weapp, swan, alipay, tt
19 */
20 openType?: keyof NavigatorProps.OpenType
21
22 /** 当 open-type 为 'navigateBack' 时有效,表示回退的层数
23 * @supported weapp, swan, tt
24 */
25 delta?: number
26
27 /** 当 `target="miniProgram"` 时有效,要打开的小程序 appId
28 * @supported weapp, swan
29 */
30 appId?: string
31
32 /** 当 `target="miniProgram"` 时有效,打开的页面路径,如果为空则打开首页
33 * @supported weapp, swan
34 */
35 path?: string
36
37 /** 当 `target="miniProgram"` 时有效,需要传递给目标小程序的数据,目标小程序可在 `App.onLaunch()`,`App.onShow()` 中获取到这份数据.
38 * @supported weapp, swan
39 */
40 extraData?: object
41
42 /** 当 `target="miniProgram"` 时有效,要打开的小程序版本
43 * @supported weapp, swan
44 */
45 version?: keyof NavigatorProps.Version
46
47 /** 指定按下去的样式类。当 `hover-class="none"` 时,没有点击态效果
48 * @default "navigator-hover"
49 * @supported weapp, swan, alipay, tt
50 */
51 hoverClass?: string
52
53 /** 指定是否阻止本节点的祖先节点出现点击态
54 * @default false
55 * @supported weapp, swan, tt
56 */
57 hoverStopPropagation?: boolean
58
59 /** 按住后多久出现点击态,单位毫秒
60 * @default 50
61 * @supported weapp, swan, alipay, tt
62 */
63 hoverStartTime?: number
64
65 /** 手指松开后点击态保留时间,单位毫秒
66 * @default 600
67 * @supported weapp, swan, alipay, tt
68 */
69 hoverStayTime?: number
70
71 /** 当 `target="miniProgram"` 时有效,跳转小程序成功
72 * @supported weapp, swan
73 */
74 onSuccess?: CommonEventFunction
75
76 /** 当 `target="miniProgram"` 时有效,跳转小程序失败
77 * @supported weapp, swan
78 */
79 onFail?: CommonEventFunction
80
81 /** 当 `target="miniProgram"` 时有效,跳转小程序完成
82 * @supported weapp, swan
83 */
84 onComplete?: CommonEventFunction
85}
86
87declare namespace NavigatorProps {
88 /** target 的合法值 */
89 interface Target {
90 /** 当前小程序 */
91 self
92 /** 其它小程序 */
93 miniProgram
94 }
95 /** open-type 的合法值 */
96 interface OpenType {
97 /** 对应 Taro.navigateTo 或 Taro.navigateToMiniProgram 的功能 */
98 navigate
99 /** 对应 Taro.redirectTo 的功能 */
100 redirect
101 /** 对应 Taro.switchTab 的功能 */
102 switchTab
103 /** 对应 Taro.reLaunch 的功能 */
104 reLaunch
105 /** 对应 Taro.navigateBack 的功能 */
106 navigateBack
107 /** 退出小程序,`target="miniProgram"` 时生效 */
108 exit
109 }
110 /** version 的合法值 */
111 interface Version {
112 /** 开发版 */
113 develop
114 /** 体验版 */
115 trial
116 /** 正式版,仅在当前小程序为开发版或体验版时此参数有效;如果当前小程序是正式版,则打开的小程序必定是正式版。 */
117 release
118 }
119}
120
121/** 页面链接
122 * @classification navig
123 * @supported weapp, swan, alipay, tt
124 * @see https://developers.weixin.qq.com/miniprogram/dev/component/navigator.html
125 */
126declare const Navigator: ComponentType<NavigatorProps>
127
128export { Navigator, NavigatorProps }