weapp.d.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /// <reference types="miniprogram-api-typings" />
  2. export declare namespace Weapp {
  3. export interface FormField {
  4. data: {
  5. name: string;
  6. value: any;
  7. };
  8. }
  9. /**
  10. * relation定义,miniprogram-api-typings缺少this定义
  11. */
  12. export interface RelationOption<Instance> {
  13. /** 目标组件的相对关系 */
  14. type: 'parent' | 'child' | 'ancestor' | 'descendant';
  15. /** 关系生命周期函数,当关系被建立在页面节点树中时触发,触发时机在组件attached生命周期之后 */
  16. linked?(
  17. this: Instance,
  18. target: WechatMiniprogram.Component.TrivialInstance
  19. ): void;
  20. /** 关系生命周期函数,当关系在页面节点树中发生改变时触发,触发时机在组件moved生命周期之后 */
  21. linkChanged?(
  22. this: Instance,
  23. target: WechatMiniprogram.Component.TrivialInstance
  24. ): void;
  25. /** 关系生命周期函数,当关系脱离页面节点树时触发,触发时机在组件detached生命周期之后 */
  26. unlinked?(
  27. this: Instance,
  28. target: WechatMiniprogram.Component.TrivialInstance
  29. ): void;
  30. /** 如果这一项被设置,则它表示关联的目标节点所应具有的behavior,所有拥有这一behavior的组件节点都会被关联 */
  31. target?: string;
  32. }
  33. /**
  34. * obverser定义,miniprogram-api-typings缺少this定义
  35. */
  36. type Observer<Instance, T> = (
  37. this: Instance,
  38. newVal: T,
  39. oldVal: T,
  40. changedPath: Array<string | number>
  41. ) => void;
  42. /**
  43. * methods定义,miniprogram-api-typings缺少this定义
  44. */
  45. export interface MethodOption<Instance> {
  46. [name: string]: (this: Instance, ...args: any[]) => any;
  47. }
  48. export interface ComputedOption<Instance> {
  49. [name: string]: (this: Instance) => any;
  50. }
  51. type PropertyType =
  52. | StringConstructor
  53. | NumberConstructor
  54. | BooleanConstructor
  55. | ArrayConstructor
  56. | ObjectConstructor
  57. | FunctionConstructor
  58. | null;
  59. export interface PropertyOption {
  60. [name: string]:
  61. | PropertyType
  62. | PropertyType[]
  63. | {
  64. /** 属性类型 */
  65. type: PropertyType | PropertyType[];
  66. /** 属性初始值 */
  67. value?: any;
  68. /** 属性值被更改时的响应函数 */
  69. observer?:
  70. | string
  71. | Observer<WechatMiniprogram.Component.TrivialInstance, any>;
  72. /** 属性的类型(可以指定多个) */
  73. optionalTypes?: PropertyType[];
  74. };
  75. }
  76. export {};
  77. }