UNPKG

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