vue.d.ts 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import {
  2. Component,
  3. AsyncComponent,
  4. FilterOptions,
  5. DirectiveOptions,
  6. DirectiveFunction,
  7. ComponentOptions,
  8. WatchHandler,
  9. WatchOptions,
  10. TransitionOptions
  11. } from './options';
  12. import { PluginObject, PluginFunction } from './plugin'
  13. type Dictionary<T> = {
  14. [key: string]: T;
  15. };
  16. type Plugin<T> = PluginFunction<T> | PluginObject<T>;
  17. type Filter = Function | FilterOptions;
  18. type Directive = DirectiveFunction<Vue> | DirectiveOptions<Vue>;
  19. export declare class Vue {
  20. constructor(options?: ComponentOptions<Vue>);
  21. $data: any;
  22. readonly $el: HTMLElement;
  23. readonly $options: ComponentOptions<Vue>;
  24. readonly $parent: Vue;
  25. readonly $root: Vue;
  26. readonly $children: Vue[];
  27. readonly $refs: Dictionary<Vue | Vue[]>;
  28. readonly $els: Dictionary<Element | Element[]>;
  29. $watch(
  30. expOrFn: string | Function,
  31. callback: WatchHandler<this>,
  32. options?: WatchOptions
  33. ): () => void;
  34. $get(expression: string): any;
  35. $set<T>(keypath: string, value: T): T;
  36. $delete(key: string): void;
  37. $eval(expression: string): any;
  38. $interpolate(templateString: string): any;
  39. $log(keypath?: string): void;
  40. $on(event: string, callback: Function): this;
  41. $once(event: string, callback: Function): this;
  42. $off(event: string, callback?: Function): this;
  43. $emit(event: string, ...args: any[]): this;
  44. $broadcast(event: string, ...args: any[]): this;
  45. $dispatch(event: string, ...args: any[]): this;
  46. $appendTo(elementOrSelector: HTMLElement | string, callback?: Function): this;
  47. $before(elementOrSelector: HTMLElement | string, callback?: Function): this;
  48. $after(elementOrSelector: HTMLElement | string, callback?: Function): this;
  49. $remove(callback?: Function): this;
  50. $nextTick(callback: (this: this) => void): void;
  51. $mount(elementOrSelector?: HTMLElement | string): this;
  52. $destroy(remove?: boolean): void;
  53. static extend(options: ComponentOptions<Vue>): typeof Vue;
  54. static nextTick(callback: () => void, context?: any[]): void;
  55. static set<T>(object: any, key: string, value: T): T;
  56. static delete(object: any, key: string): void;
  57. static directive<T extends Directive>(id: string, definition?: T): T;
  58. static elementDirective<T extends Directive>(id: string, definition?: T): T;
  59. static filter<T extends Filter>(id: string, definition?: T): T;
  60. static component<V extends Vue>(id: string, definition?: ComponentOptions<V> | AsyncComponent): ComponentOptions<V>;
  61. static transition(id: string, hooks?: TransitionOptions): TransitionOptions;
  62. static partial(id: string, partial?: string): string;
  63. static use<T>(plugin: Plugin<T>, options?: T): void;
  64. static mixin(mixin: Component): void;
  65. static config: {
  66. debug: boolean;
  67. delimiters: [string, string];
  68. unsafeDelimiters: [string, string];
  69. silent: boolean;
  70. async: boolean;
  71. devtools: boolean;
  72. }
  73. }