UNPKG

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