vue.d.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 | Function,
  46. callback: WatchHandler<this>,
  47. options?: WatchOptions
  48. ): (() => void);
  49. $on(event: string, callback: Function): this;
  50. $once(event: string, callback: Function): this;
  51. $off(event?: string, callback?: Function): this;
  52. $emit(event: string, ...args: any[]): this;
  53. $nextTick(callback: (this: this) => void): void;
  54. $nextTick(): Promise<void>;
  55. $createElement: CreateElement;
  56. static config: {
  57. silent: boolean;
  58. optionMergeStrategies: any;
  59. devtools: boolean;
  60. errorHandler(err: Error, vm: Vue): void;
  61. keyCodes: { [key: string]: number };
  62. }
  63. static extend(options: ComponentOptions<Vue> | FunctionalComponentOptions): typeof Vue;
  64. static nextTick(callback: () => void, context?: any[]): void;
  65. static nextTick(): Promise<void>
  66. static set<T>(object: Object, key: string, value: T): T;
  67. static set<T>(array: T[], key: number, value: T): T;
  68. static delete(object: Object, key: string): void;
  69. static directive(
  70. id: string,
  71. definition?: DirectiveOptions | DirectiveFunction
  72. ): DirectiveOptions;
  73. static filter(id: string, definition?: Function): Function;
  74. static component(id: string, definition?: Component | AsyncComponent): typeof Vue;
  75. static use<T>(plugin: PluginObject<T> | PluginFunction<T>, options?: T): void;
  76. static mixin(mixin: typeof Vue | ComponentOptions<Vue>): void;
  77. static compile(template: string): {
  78. render(createElement: typeof Vue.prototype.$createElement): VNode;
  79. staticRenderFns: (() => VNode)[];
  80. };
  81. }