vue.d.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import {
  2. Component,
  3. AsyncComponent,
  4. ComponentOptions,
  5. FunctionalComponentOptions,
  6. WatchOptions,
  7. WatchHandler,
  8. DirectiveOptions,
  9. DirectiveFunction
  10. } from "./options";
  11. import { VNode, VNodeData, VNodeChildren, ScopedSlot } from "./vnode";
  12. import { PluginFunction, PluginObject } from "./plugin";
  13. export type CreateElement = {
  14. // empty node
  15. (): VNode;
  16. // element or component name
  17. (tag: string, children: VNodeChildren): VNode;
  18. (tag: string, data?: VNodeData, children?: VNodeChildren): VNode;
  19. // component constructor or options
  20. (tag: Component, children: VNodeChildren): VNode;
  21. (tag: Component, data?: VNodeData, children?: VNodeChildren): VNode;
  22. // async component
  23. (tag: AsyncComponent, children: VNodeChildren): VNode;
  24. (tag: AsyncComponent, data?: VNodeData, children?: VNodeChildren): VNode;
  25. }
  26. export declare class Vue {
  27. constructor(options?: ComponentOptions<Vue>);
  28. $data: Object;
  29. readonly $el: HTMLElement;
  30. readonly $options: ComponentOptions<this>;
  31. readonly $parent: Vue;
  32. readonly $root: Vue;
  33. readonly $children: Vue[];
  34. readonly $refs: { [key: string]: Vue | Element | Vue[] | Element[]};
  35. readonly $slots: { [key: string]: VNode[] };
  36. readonly $scopedSlots: { [key: string]: ScopedSlot };
  37. readonly $isServer: boolean;
  38. readonly $props: any;
  39. $mount(elementOrSelector?: Element | String, hydrating?: boolean): this;
  40. $forceUpdate(): void;
  41. $destroy(): void;
  42. $set: typeof Vue.set;
  43. $delete: typeof Vue.delete;
  44. $watch(
  45. expOrFn: string,
  46. callback: WatchHandler<this, any>,
  47. options?: WatchOptions
  48. ): (() => void);
  49. $watch<T>(
  50. expOrFn: (this: this) => T,
  51. callback: WatchHandler<this, T>,
  52. options?: WatchOptions
  53. ): (() => void);
  54. $on(event: string | string[], callback: Function): this;
  55. $once(event: string, callback: Function): this;
  56. $off(event?: string | string[], callback?: Function): this;
  57. $emit(event: string, ...args: any[]): this;
  58. $nextTick(callback: (this: this) => void): void;
  59. $nextTick(): Promise<void>;
  60. $createElement: CreateElement;
  61. static config: {
  62. silent: boolean;
  63. optionMergeStrategies: any;
  64. devtools: boolean;
  65. productionTip: boolean;
  66. performance: boolean;
  67. errorHandler(err: Error, vm: Vue, info: string): void;
  68. ignoredElements: string[];
  69. keyCodes: { [key: string]: number };
  70. }
  71. static extend(options: ComponentOptions<Vue> | FunctionalComponentOptions): typeof Vue;
  72. static nextTick(callback: () => void, context?: any[]): void;
  73. static nextTick(): Promise<void>
  74. static set<T>(object: Object, key: string, value: T): T;
  75. static set<T>(array: T[], key: number, value: T): T;
  76. static delete(object: Object, key: string): void;
  77. static directive(
  78. id: string,
  79. definition?: DirectiveOptions | DirectiveFunction
  80. ): DirectiveOptions;
  81. static filter(id: string, definition?: Function): Function;
  82. static component(id: string, definition?: Component | AsyncComponent): typeof Vue;
  83. static use<T>(plugin: PluginObject<T> | PluginFunction<T>, options?: T): void;
  84. static mixin(mixin: typeof Vue | ComponentOptions<Vue>): void;
  85. static compile(template: string): {
  86. render(createElement: typeof Vue.prototype.$createElement): VNode;
  87. staticRenderFns: (() => VNode)[];
  88. };
  89. }