vue.d.ts 2.8 KB

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