@@ -6,67 +6,6 @@ declare namespace MiniProgram.Component {
66 ExtraOptions extends UnknownRecord
77 > { }
88
9- interface IMediaQueryObserver {
10- /**
11- * 开始监听页面 media query 变化情况
12- * @param descriptor media query 描述符
13- * @param callback 监听 media query 状态变化的回调函数
14- * @see https://opendocs.alipay.com/mini/05awpq
15- */
16- observe : (
17- descriptor : IMediaQueryObserveDescriptor ,
18- callback : IMediaQueryObserveCallback
19- ) => void ;
20- /**
21- * 停止监听。回调函数将不再触发
22- * @see https://opendocs.alipay.com/mini/05bb9o
23- */
24- disconnect : ( ) => void ;
25- }
26-
27- type IMediaQueryObserveCallback = (
28- payload : IMediaQueryObserveCallbackResponse
29- ) => void ;
30-
31- interface IMediaQueryObserveCallbackResponse {
32- /**
33- * 页面的当前状态是否满足所指定的 media query
34- */
35- matches : boolean ;
36- }
37- interface IMediaQueryObserveDescriptor {
38- /**
39- * 页面最小宽度( px 为单位)
40- */
41- minWidth ?: number ;
42- /**
43- * 页面最大宽度( px 为单位)
44- */
45- maxWidth ?: number ;
46- /**
47- * 页面宽度( px 为单位)
48- */
49- width ?: number ;
50- /**
51- * 页面最小高度( px 为单位)
52- */
53- minHeight ?: number ;
54- /**
55- * 页面最大高度( px 为单位)
56- */
57- maxHeight ?: number ;
58- /**
59- * 页面高度( px 为单位)
60- */
61- height ?: number ;
62- /**
63- * 屏幕方向( landscape 或 portrait )
64- * - landscape viewport 处于横向,即宽度大于高度。
65- * - portrait viewport 处于纵向,即高度大于等于宽度。
66- */
67- orientation ?: 'landscape' | 'portrait' ;
68- }
69-
709 interface ILifetimes {
7110 /**
7211 * 在组件实例刚刚被创建时执行
@@ -238,219 +177,13 @@ declare namespace MiniProgram.Component {
238177 * @description 可获得当前自定义组件的路由对象,路由方法与全局路由方法功能相同,唯一区别在于调用时,相对路径是相对于该自定义组件
239178 * @version 2.7.22
240179 */
241- readonly router : IRouter ;
180+ readonly router : Shared . IRouter ;
242181 /**
243182 * 自定义组件所在页面路由对象
244183 * @description 可获得当前自定义组件所在页面的路由对象,路由方法与全局路由方法功能相同,唯一区别在于调用时,相对路径是相对于所在页面
245184 * @version 2.7.22
246185 */
247- readonly pageRouter : IRouter ;
248- }
249-
250- interface IRouter {
251- navigateTo : ( r : {
252- /**
253- * 需要跳转的目标页面路径
254- * @description 路径后可以带参数, 目标路径必须为应用内非 tabbar 的,路径与参数之间使用 ?分隔,参数键与参数值用=相连,不同参数必须用&分隔
255- */
256- url : string ;
257- /**
258- * 页面间通信接口,用于监听被打开页面发送到当前页面的数据
259- */
260- events ?: IMyNavigateToEvents ;
261- /**
262- * 接口调用成功的回调函数
263- */
264- success ?( data : {
265- /**
266- * 和被打开页面进行通信
267- */
268- eventChannel : EventChannel ;
269- } ) : void ;
270- /**
271- * 接口调用失败的回调函数
272- */
273- fail ?( err : { error ?: number ; errorMessage ?: string } ) : void ;
274- /**
275- * 接口调用结束的回调函数(调用成功、失败都会执行)
276- */
277- complete ?(
278- arg :
279- | {
280- /**
281- * 和被打开页面进行通信
282- */
283- eventChannel : EventChannel ;
284- }
285- | {
286- error ?: number ;
287- errorMessage ?: string ;
288- }
289- ) : void ;
290- } ) => Promise < {
291- /**
292- * 和被打开页面进行通信
293- */
294- eventChannel : EventChannel ;
295- } > ;
296- redirectTo : ( r : {
297- /**
298- * 需要跳转的目标页面路径
299- * 路径后可以带参数, 目标路径必须为应用内非 tabbar 的,路径与参数之间使用 ?分隔,参数键与参数值用=相连,不同参数必须用&分隔
300- */
301- url : string ;
302- /**
303- * 接口调用成功的回调函数
304- */
305- success ?( data : { } ) : void ;
306- /**
307- * 接口调用失败的回调函数
308- */
309- fail ?( err : { error ?: number ; errorMessage ?: string } ) : void ;
310- /**
311- * 接口调用结束的回调函数(调用成功、失败都会执行)
312- */
313- complete ?( arg : { error ?: number ; errorMessage ?: string } ) : void ;
314- } ) => Promise < void > ;
315- navigateBack : ( r ?: {
316- /**
317- * 返回的页面数
318- * @description 如果 delta 大于现有打开的页面数,则返回到首页
319- * @default 1
320- */
321- delta ?: number | string ;
322- /**
323- * 接口调用成功的回调函数
324- */
325- success ?( data : { } ) : void ;
326- /**
327- * 接口调用失败的回调函数
328- */
329- fail ?( err : { error ?: number ; errorMessage ?: string } ) : void ;
330- /**
331- * 接口调用结束的回调函数(调用成功、失败都会执行)
332- */
333- complete ?( arg : { error ?: number ; errorMessage ?: string } ) : void ;
334- } ) => Promise < void > ;
335- switchTab : ( r : {
336- /**
337- * 跳转的特定 tab 的路径
338- * @description 目标路径必须为应用内 tabbar 的,且路径后不能带参数
339- */
340- url : string ;
341- /**
342- * 接口调用成功的回调函数
343- */
344- success ?( data : { } ) : void ;
345- /**
346- * 接口调用失败的回调函数
347- */
348- fail ?( err : { error ?: number ; errorMessage ?: string } ) : void ;
349- /**
350- * 接口调用结束的回调函数(调用成功、失败都会执行)
351- */
352- complete ?( arg : { error ?: number ; errorMessage ?: string } ) : void ;
353- } ) => Promise < void > ;
354- reLaunch : ( r : {
355- /**
356- * 需要跳转的目标页面路径
357- * @description
358- * 目标路径如果是 Tab 路径后不可以带参数
359- * 目标路径如果是非 Tab 页,可以携带参数,路径与参数之间使用 `?` 分隔,参数键与参数值用 `=` 相连,不同参数必须用 `&` 分隔
360- */
361- url : string ;
362- /**
363- * 接口调用成功的回调函数
364- */
365- success ?( data : { } ) : void ;
366- /**
367- * 接口调用失败的回调函数
368- */
369- fail ?( err : { error ?: number ; errorMessage ?: string } ) : void ;
370- /**
371- * 接口调用结束的回调函数(调用成功、失败都会执行)
372- */
373- complete ?( arg : { error ?: number ; errorMessage ?: string } ) : void ;
374- } ) => Promise < void > ;
375- }
376- interface IMyNavigateToEvents {
377- /**
378- * 特定事件名监听回调
379- */
380- [ eventName : string ] : ( ...args : unknown [ ] ) => void ;
381- }
382- interface EventChannel {
383- /**
384- * 在页面间通信中触发一个事件
385- * @see https://opendocs.alipay.com/mini/api/eventchannel.emit
386- */
387- emit ( eventName : string , args ?: unknown ) : void ;
388- /**
389- * 在页面间通信中停止监听一个事件
390- * @see https://opendocs.alipay.com/mini/api/eventchannel.off
391- */
392- off ( eventName : string , callback : ( ...args : unknown [ ] ) => void ) : void ;
393- /**
394- * 在页面间通信中持续监听一个事件
395- * @see https://opendocs.alipay.com/mini/api/eventchannel.on
396- */
397- on ( eventName : string , callback : ( ...args : unknown [ ] ) => void ) : void ;
398- /**
399- * 在页面间通信中监听一个事件仅一次
400- * @description 事件触发后失效
401- * @see https://opendocs.alipay.com/mini/api/eventchannel.once
402- */
403- once ( eventName : string , callback : ( ...args : unknown [ ] ) => void ) : void ;
404- }
405-
406- interface IInstanceSharedMethods < Data > {
407- /**
408- * 创建 SelectorQuery 对象实例。
409- * @version 2.7.4
410- */
411- createSelectorQuery ( ) : any ;
412- /**
413- * 创建 IntersectionObserver 对象实例。
414- * @version 2.7.4
415- */
416- createIntersectionObserver ( ) : any ;
417- /**
418- * 创建 MediaQueryObserver 对象实例,用于监听页面 media query 状态的变化。
419- * @version 2.8.2
420- */
421- createMediaQueryObserver ( ) : IMediaQueryObserver ;
422- /**
423- * 获取自定义 tabBar 实例,可以通过判断 `this.getTabBar` 是否为一个函数做兼容性处理
424- * @version 2.7.20
425- */
426- getTabBar < T extends any = BaseInstance > ( ) : T | undefined ;
427- /**
428- * 查询子组件
429- * @description 根据传入的 selector 匹配器查询,返回匹配到的第一个组件实例(会被 ref 影响)
430- * @version 2.8.0
431- */
432- $selectComponent ( selector : string ) : BaseInstance | void ;
433- /**
434- * 查询子组件
435- * @description 根据传入的 selector 匹配器查询,返回匹配到的所有组件实例(会被 ref 影响)
436- * @version 2.8.0
437- */
438- $selectAllComponents ( selector : string ) : BaseInstance [ ] ;
439- /**
440- * 检查组件是否具有 mixin(须是通过Mixin()创建的mixin实例)。
441- * @description 若自定义组件注册时传入了ref以指定组件返回值,则可通过hasMixin('ref')检查到
442- * @version 基础库 2.8.2
443- * @return boolean
444- */
445- hasMixin ( mixin : Mixin . IMixinIdentifier ) : boolean ;
446- /**
447- * 监听 setData 引发界面更新的开销,参见 获取更新性能统计信息
448- * @version 2.8.5
449- */
450- setUpdatePerformanceListener < WithDataPath extends boolean = false > (
451- option : Shared . SetUpdatePerformanceListenerOption < WithDataPath > ,
452- callback ?: Shared . UpdatePerformanceListener < WithDataPath >
453- ) : void ;
186+ readonly pageRouter : Shared . IRouter ;
454187 }
455188
456189 interface IInstanceMethods < Data > {
@@ -519,7 +252,7 @@ declare namespace MiniProgram.Component {
519252 IComponentInstanceAdditionalProperties < ExtraOptions > &
520253 IInstanceProperties &
521254 IInstanceMethods < Data > &
522- IInstanceSharedMethods < Data > ;
255+ Shared . IInstanceSharedMethods < Data > ;
523256
524257 type BaseInstance = IInstance <
525258 UnknownRecord ,
0 commit comments