vue.d.ts 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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, callback: Function): this;
  55. $once(event: string, callback: Function): this;
  56. $off(event?: 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. errorHandler(err: Error, vm: Vue): void;
  66. keyCodes: { [key: string]: number };
  67. }
  68. static extend(options: ComponentOptions<Vue> | FunctionalComponentOptions): typeof Vue;
  69. static nextTick(callback: () => void, context?: any[]): void;
  70. static nextTick(): Promise<void>
  71. static set<T>(object: Object, key: string, value: T): T;
  72. static set<T>(array: T[], key: number, value: T): T;
  73. static delete(object: Object, key: string): void;
  74. static directive(
  75. id: string,
  76. definition?: DirectiveOptions | DirectiveFunction
  77. ): DirectiveOptions;
  78. static filter(id: string, definition?: Function): Function;
  79. static component(id: string, definition?: Component | AsyncComponent): typeof Vue;
  80. static use<T>(plugin: PluginObject<T> | PluginFunction<T>, options?: T): void;
  81. static mixin(mixin: typeof Vue | ComponentOptions<Vue>): void;
  82. static compile(template: string): {
  83. render(createElement: typeof Vue.prototype.$createElement): VNode;
  84. staticRenderFns: (() => VNode)[];
  85. };
  86. }