Documentación offline Vue 3 main

Global API: General

main Documentación oficial Licencia MITDescargado el 2026-08-02

En esta página

Global API: General#

version#

Exposes the current version of Vue.

  • Type: string

  • Example

```js import { version } from 'vue'

console.log(version) ```

nextTick()#

A utility for waiting for the next DOM update flush.

  • Type

ts function nextTick(callback?: () => void): Promise<void>

  • Details

When you mutate reactive state in Vue, the resulting DOM updates are not applied synchronously. Instead, Vue buffers them until the "next tick" to ensure that each component updates only once no matter how many state changes you have made.

nextTick() can be used immediately after a state change to wait for the DOM updates to complete. You can either pass a callback as an argument, or await the returned Promise.

  • Example
```vue ```
```vue ```

defineComponent()#

A type helper for defining a Vue component with type inference.

  • Type

```ts // options syntax function defineComponent( component: ComponentOptions ): ComponentConstructor

// function syntax (requires 3.3+) function defineComponent( setup: ComponentOptions['setup'], extraOptions?: ComponentOptions ): () => any ```

Type is simplified for readability.

  • Details

The first argument expects a component options object. The return value will be the same options object, since the function is essentially a runtime no-op for type inference purposes only.

Note that the return type is a bit special: it will be a constructor type whose instance type is the inferred component instance type based on the options. This is used for type inference when the returned type is used as a tag in TSX.

You can extract the instance type of a component (equivalent to the type of this in its options) from the return type of defineComponent() like this:

```ts const Foo = defineComponent(/ ... /)

type FooInstance = InstanceType ```

### Function Signature {#function-signature}

  • Only supported in 3.3+

defineComponent() also has an alternative signature that is meant to be used with the Composition API and render functions or JSX.

Instead of passing in an options object, a function is expected instead. This function works the same as the Composition API setup() function: it receives the props and the setup context. The return value should be a render function - both h() and JSX are supported:

```js import { ref, h } from 'vue'

const Comp = defineComponent( (props) => { // use Composition API here like in