url
stringlengths
24
106
html
stringlengths
41
53k
title
stringlengths
0
63
https://vuejs.org/guide/essentials/component-basics.html#VPContent
Components Basics ​ Components allow us to split the UI into independent and reusable pieces, and think about each piece in isolation. It's common for an app to be organized into a tree of nested components: This is very similar to how we nest native HTML elements, but Vue implements its own component model that allo...
Components Basics | Vue.js
https://vuejs.org/guide/essentials/template-refs.html#VPContent
Template Refs ​ While Vue's declarative rendering model abstracts away most of the direct DOM operations for you, there may still be cases where we need direct access to the underlying DOM elements. To achieve this, we can use the special ref attribute: template <input ref="input"> ref is a special attribute, simila...
Template Refs | Vue.js
https://vuejs.org/guide/essentials/lifecycle.html#VPContent
Lifecycle Hooks ​ Each Vue component instance goes through a series of initialization steps when it's created - for example, it needs to set up data observation, compile the template, mount the instance to the DOM, and update the DOM when data changes. Along the way, it also runs functions called lifecycle hooks, givi...
Lifecycle Hooks | Vue.js
https://vuejs.org/guide/essentials/watchers.html#VPContent
Watchers ​ Basic Example ​ Computed properties allow us to declaratively compute derived values. However, there are cases where we need to perform "side effects" in reaction to state changes - for example, mutating the DOM, or changing another piece of state based on the result of an async operation. With Composition...
Watchers | Vue.js
https://vuejs.org/guide/essentials/event-handling.html#VPContent
Event Handling ​ Watch a free video lesson on Vue School Listening to Events ​ We can use the v-on directive, which we typically shorten to the @ symbol, to listen to DOM events and run some JavaScript when they're triggered. The usage would be v-on:click="handler" or with the shortcut, @click="handler". The handler ...
Event Handling | Vue.js
https://vuejs.org/guide/essentials/conditional.html#VPContent
Conditional Rendering ​ Watch a free video lesson on Vue School v-if ​ The directive v-if is used to conditionally render a block. The block will only be rendered if the directive's expression returns a truthy value. template <h1 v-if="awesome">Vue is awesome!</h1> v-else ​ You can use the v-else directive to indica...
Conditional Rendering | Vue.js
https://vuejs.org/guide/essentials/forms.html#VPContent
Form Input Bindings ​ Watch a free video lesson on Vue School When dealing with forms on the frontend, we often need to sync the state of form input elements with corresponding state in JavaScript. It can be cumbersome to manually wire up value bindings and change event listeners: template <input :value="text" @i...
Form Input Bindings | Vue.js
https://vuejs.org/guide/essentials/list.html#VPContent
List Rendering ​ Watch a free video lesson on Vue School v-for ​ We can use the v-for directive to render a list of items based on an array. The v-for directive requires a special syntax in the form of item in items, where items is the source data array and item is an alias for the array element being iterated on: js...
List Rendering | Vue.js
https://vuejs.org/guide/essentials/class-and-style.html#VPContent
Class and Style Bindings ​ A common need for data binding is manipulating an element's class list and inline styles. Since class and style are both attributes, we can use v-bind to assign them a string value dynamically, much like with other attributes. However, trying to generate those values using string concatenati...
Class and Style Bindings | Vue.js
https://vuejs.org/guide/essentials/computed.html#VPContent
Computed Properties ​ Watch a free video lesson on Vue School Basic Example ​ In-template expressions are very convenient, but they are meant for simple operations. Putting too much logic in your templates can make them bloated and hard to maintain. For example, if we have an object with a nested array: js const auth...
Computed Properties | Vue.js
https://vuejs.org/guide/essentials/template-syntax.html#VPContent
Template Syntax ​ Vue uses an HTML-based template syntax that allows you to declaratively bind the rendered DOM to the underlying component instance's data. All Vue templates are syntactically valid HTML that can be parsed by spec-compliant browsers and HTML parsers. Under the hood, Vue compiles the templates into hi...
Template Syntax | Vue.js
https://vuejs.org/guide/essentials/reactivity-fundamentals.html#VPContent
Reactivity Fundamentals ​ API Preference This page and many other chapters later in the guide contain different content for the Options API and the Composition API. Your current preference is Composition API. You can toggle between the API styles using the "API Preference" switches at the top of the left sidebar. De...
Reactivity Fundamentals | Vue.js
https://vuejs.org/guide/essentials/application.html#VPContent
Creating a Vue Application ​ The application instance ​ Every Vue application starts by creating a new application instance with the createApp function: js import { createApp } from 'vue' const app = createApp({ /* root component options */ }) The Root Component ​ The object we are passing into createApp is in fa...
Creating a Vue Application | Vue.js
https://vuejs.org/guide/scaling-up/tooling.html#VPContent
Tooling ​ Try It Online ​ You don't need to install anything on your machine to try out Vue SFCs - there are online playgrounds that allow you to do so right in the browser: Vue SFC Playground Always deployed from latest commit Designed for inspecting component compilation results Vue + Vite on StackBlitz IDE-like en...
Tooling | Vue.js
https://vuejs.org/guide/quick-start.html#VPContent
Quick Start ​ Try Vue Online ​ To quickly get a taste of Vue, you can try it directly in our Playground. If you prefer a plain HTML setup without any build steps, you can use this JSFiddle as your starting point. If you are already familiar with Node.js and the concept of build tools, you can also try a complete bui...
Quick Start | Vue.js
https://vuejs.org/guide/extras/animation.html
Animation Techniques ​ Vue provides the <Transition> and <TransitionGroup> components for handling enter / leave and list transitions. However, there are many other ways of using animations on the web, even in a Vue application. Here we will discuss a few additional techniques. Class-based Animations ​ For elements ...
Animation Techniques | Vue.js
https://vuejs.org/guide/extras/web-components.html
Vue and Web Components ​ Web Components is an umbrella term for a set of web native APIs that allows developers to create reusable custom elements. We consider Vue and Web Components to be primarily complementary technologies. Vue has excellent support for both consuming and creating custom elements. Whether you are ...
Vue and Web Components | Vue.js
https://vuejs.org/guide/extras/render-function.html
Render Functions & JSX ​ Vue recommends using templates to build applications in the vast majority of cases. However, there are situations where we need the full programmatic power of JavaScript. That's where we can use the render function. If you are new to the concept of virtual DOM and render functions, make sure ...
Render Functions & JSX | Vue.js
https://vuejs.org/guide/extras/rendering-mechanism.html
Rendering Mechanism ​ How does Vue take a template and turn it into actual DOM nodes? How does Vue update those DOM nodes efficiently? We will attempt to shed some light on these questions here by diving into Vue's internal rendering mechanism. Virtual DOM ​ You have probably heard about the term "virtual DOM", whic...
Rendering Mechanism | Vue.js
https://vuejs.org/guide/extras/reactivity-in-depth.html
Reactivity in Depth ​ One of Vue’s most distinctive features is the unobtrusive reactivity system. Component state consists of reactive JavaScript objects. When you modify them, the view updates. It makes state management simple and intuitive, but it’s also important to understand how it works to avoid some common got...
Reactivity in Depth | Vue.js
https://vuejs.org/guide/extras/composition-api-faq.html
Composition API FAQ ​ TIP This FAQ assumes prior experience with Vue - in particular, experience with Vue 2 while primarily using Options API. What is Composition API? ​ Watch a free video lesson on Vue School Composition API is a set of APIs that allows us to author Vue components using imported functions instead ...
Composition API FAQ | Vue.js
https://vuejs.org/guide/extras/ways-of-using-vue.html
Ways of Using Vue ​ We believe there is no "one size fits all" story for the web. This is why Vue is designed to be flexible and incrementally adoptable. Depending on your use case, Vue can be used in different ways to strike the optimal balance between stack complexity, developer experience and end performance. Stan...
Ways of Using Vue | Vue.js
https://vuejs.org/guide/typescript/options-api.html
TypeScript with Options API ​ This page assumes you've already read the overview on Using Vue with TypeScript. TIP While Vue does support TypeScript usage with Options API, it is recommended to use Vue with TypeScript via Composition API as it offers simpler, more efficient and more robust type inference. Typing Co...
TypeScript with Options API | Vue.js
https://vuejs.org/guide/typescript/composition-api.html
TypeScript with Composition API ​ This page assumes you've already read the overview on Using Vue with TypeScript. Typing Component Props ​ Using <script setup> ​ When using <script setup>, the defineProps() macro supports inferring the props types based on its argument: vue <script setup lang="ts"> const props = d...
TypeScript with Composition API | Vue.js
https://vuejs.org/guide/typescript/overview.html
Using Vue with TypeScript ​ A type system like TypeScript can detect many common errors via static analysis at build time. This reduces the chance of runtime errors in production, and also allows us to more confidently refactor code in large-scale applications. TypeScript also improves developer ergonomics via type-ba...
Using Vue with TypeScript | Vue.js
https://vuejs.org/guide/best-practices/security.html
Security ​ Reporting Vulnerabilities ​ When a vulnerability is reported, it immediately becomes our top concern, with a full-time contributor dropping everything to work on it. To report a vulnerability, please email security@vuejs.org. While the discovery of new vulnerabilities is rare, we also recommend always usin...
Security | Vue.js
https://vuejs.org/guide/best-practices/accessibility.html
Accessibility ​ Web accessibility (also known as a11y) refers to the practice of creating websites that can be used by anyone β€” be that a person with a disability, a slow connection, outdated or broken hardware or simply someone in an unfavorable environment. For example, adding subtitles to a video would help both yo...
Accessibility | Vue.js
https://vuejs.org/guide/best-practices/performance.html
Performance ​ Overview ​ Vue is designed to be performant for most common use cases without much need for manual optimizations. However, there are always challenging scenarios where extra fine-tuning is needed. In this section, we will discuss what you should pay attention to when it comes to performance in a Vue appl...
Performance | Vue.js
https://vuejs.org/guide/best-practices/production-deployment.html
Production Deployment ​ Development vs. Production ​ During development, Vue provides a number of features to improve the development experience: Warning for common errors and pitfalls Props / events validation Reactivity debugging hooks Devtools integration However, these features become useless in production. Some...
Production Deployment | Vue.js
https://vuejs.org/guide/scaling-up/ssr.html
Server-Side Rendering (SSR) ​ Overview ​ What is SSR? ​ Vue.js is a framework for building client-side applications. By default, Vue components produce and manipulate DOM in the browser as output. However, it is also possible to render the same components into HTML strings on the server, send them directly to the brow...
Server-Side Rendering (SSR) | Vue.js
https://vuejs.org/guide/scaling-up/testing.html
Testing ​ Why Test? ​ Automated tests help you and your team build complex Vue applications quickly and confidently by preventing regressions and encouraging you to break apart your application into testable functions, modules, classes, and components. As with any application, your new Vue app can break in many ways, ...
Testing | Vue.js
https://vuejs.org/guide/scaling-up/routing.html
Routing ​ Client-Side vs. Server-Side Routing ​ Routing on the server side means the server sending a response based on the URL path that the user is visiting. When we click on a link in a traditional server-rendered web app, the browser receives an HTML response from the server and reloads the entire page with the ne...
Routing | Vue.js
https://vuejs.org/guide/scaling-up/state-management.html
State Management ​ What is State Management? ​ Technically, every Vue component instance already "manages" its own reactive state. Take a simple counter component as an example: vue <script setup> import { ref } from 'vue' // state const count = ref(0) // actions function increment() { count.value++ } </script> ...
State Management | Vue.js
https://vuejs.org/guide/scaling-up/sfc.html
Single-File Components ​ Introduction ​ Vue Single-File Components (a.k.a. *.vue files, abbreviated as SFC) is a special file format that allows us to encapsulate the template, logic, and styling of a Vue component in a single file. Here's an example SFC: vue <script setup> import { ref } from 'vue' const greeting = ...
Single-File Components | Vue.js
https://vuejs.org/guide/built-ins/suspense.html
Suspense ​ Experimental Feature <Suspense> is an experimental feature. It is not guaranteed to reach stable status and the API may change before it does. <Suspense> is a built-in component for orchestrating async dependencies in a component tree. It can render a loading state while waiting for multiple nested async ...
Suspense | Vue.js
https://vuejs.org/guide/built-ins/teleport.html
Teleport ​ Watch a free video lesson on Vue School <Teleport> is a built-in component that allows us to "teleport" a part of a component's template into a DOM node that exists outside the DOM hierarchy of that component. Basic Usage ​ Sometimes we may run into the following scenario: a part of a component's template...
Teleport | Vue.js
https://vuejs.org/guide/built-ins/keep-alive.html
KeepAlive ​ <KeepAlive> is a built-in component that allows us to conditionally cache component instances when dynamically switching between multiple components. Basic Usage ​ In the Component Basics chapter, we introduced the syntax for Dynamic Components, using the <component> special element: template <component...
KeepAlive | Vue.js
https://vuejs.org/guide/built-ins/transition-group.html
TransitionGroup ​ <TransitionGroup> is a built-in component designed for animating the insertion, removal, and order change of elements or components that are rendered in a list. Differences from <Transition> ​ <TransitionGroup> supports the same props, CSS transition classes, and JavaScript hook listeners as <Trans...
TransitionGroup | Vue.js
https://vuejs.org/guide/reusability/plugins.html
Plugins ​ Introduction ​ Plugins are self-contained code that usually add app-level functionality to Vue. This is how we install a plugin: js import { createApp } from 'vue' const app = createApp({}) app.use(myPlugin, { /* optional options */ }) A plugin is defined as either an object that exposes an install() m...
Plugins | Vue.js
https://vuejs.org/guide/built-ins/transition.html
Transition ​ Vue offers two built-in components that can help work with transitions and animations in response to changing state: <Transition> for applying animations when an element or component is entering and leaving the DOM. This is covered on this page. <TransitionGroup> for applying animations when an element ...
Transition | Vue.js
https://vuejs.org/guide/reusability/custom-directives.html
Custom Directives ​ Introduction ​ In addition to the default set of directives shipped in core (like v-model or v-show), Vue also allows you to register your own custom directives. We have introduced two forms of code reuse in Vue: components and composables. Components are the main building blocks, while composable...
Custom Directives | Vue.js
https://vuejs.org/guide/components/async.html
Async Components ​ Basic Usage ​ In large applications, we may need to divide the app into smaller chunks and only load a component from the server when it's needed. To make that possible, Vue has a defineAsyncComponent function: js import { defineAsyncComponent } from 'vue' const AsyncComp = defineAsyncComponent(()...
Async Components | Vue.js
https://vuejs.org/guide/reusability/composables.html
Composables ​ TIP This section assumes basic knowledge of Composition API. If you have been learning Vue with Options API only, you can set the API Preference to Composition API (using the toggle at the top of the left sidebar) and re-read the Reactivity Fundamentals and Lifecycle Hooks chapters. What is a "Composab...
Composables | Vue.js
https://vuejs.org/guide/components/provide-inject.html
Provide / Inject ​ This page assumes you've already read the Components Basics. Read that first if you are new to components. Prop Drilling ​ Usually, when we need to pass data from the parent to a child component, we use props. However, imagine the case where we have a large component tree, and a deeply nested comp...
Provide / Inject | Vue.js
https://vuejs.org/guide/components/slots.html
Slots ​ This page assumes you've already read the Components Basics. Read that first if you are new to components. Watch a free video lesson on Vue School Slot Content and Outlet ​ We have learned that components can accept props, which can be JavaScript values of any type. But how about template content? In some ca...
Slots | Vue.js
https://vuejs.org/guide/components/attrs.html
Fallthrough Attributes ​ This page assumes you've already read the Components Basics. Read that first if you are new to components. Attribute Inheritance ​ A "fallthrough attribute" is an attribute or v-on event listener that is passed to a component, but is not explicitly declared in the receiving component's props...
Fallthrough Attributes | Vue.js
https://vuejs.org/guide/components/v-model.html
Component v-model ​ v-model can be used on a component to implement a two-way binding. First let's revisit how v-model is used on a native element: template <input v-model="searchText" /> Under the hood, the template compiler expands v-model to the more verbose equivalent for us. So the above code does the same as ...
Component v-model | Vue.js
https://vuejs.org/guide/components/events.html
Component Events ​ This page assumes you've already read the Components Basics. Read that first if you are new to components. Emitting and Listening to Events ​ A component can emit custom events directly in template expressions (e.g. in a v-on handler) using the built-in $emit method: template <!-- MyComponent -->...
Component Events | Vue.js
https://vuejs.org/guide/components/props.html
Props ​ This page assumes you've already read the Components Basics. Read that first if you are new to components. Props Declaration ​ Vue components require explicit props declaration so that Vue knows what external props passed to the component should be treated as fallthrough attributes (which will be discussed i...
Props | Vue.js
https://vuejs.org/guide/components/registration.html
Component Registration ​ This page assumes you've already read the Components Basics. Read that first if you are new to components. Watch a free video lesson on Vue School A Vue component needs to be "registered" so that Vue knows where to locate its implementation when it is encountered in a template. There are two...
Component Registration | Vue.js
https://vuejs.org/guide/essentials/component-basics.html
Components Basics ​ Components allow us to split the UI into independent and reusable pieces, and think about each piece in isolation. It's common for an app to be organized into a tree of nested components: This is very similar to how we nest native HTML elements, but Vue implements its own component model that allo...
Components Basics | Vue.js
https://vuejs.org/guide/essentials/template-refs.html
Template Refs ​ While Vue's declarative rendering model abstracts away most of the direct DOM operations for you, there may still be cases where we need direct access to the underlying DOM elements. To achieve this, we can use the special ref attribute: template <input ref="input"> ref is a special attribute, simila...
Template Refs | Vue.js
https://vuejs.org/guide/essentials/lifecycle.html
Lifecycle Hooks ​ Each Vue component instance goes through a series of initialization steps when it's created - for example, it needs to set up data observation, compile the template, mount the instance to the DOM, and update the DOM when data changes. Along the way, it also runs functions called lifecycle hooks, givi...
Lifecycle Hooks | Vue.js
https://vuejs.org/guide/essentials/watchers.html
Watchers ​ Basic Example ​ Computed properties allow us to declaratively compute derived values. However, there are cases where we need to perform "side effects" in reaction to state changes - for example, mutating the DOM, or changing another piece of state based on the result of an async operation. With Composition...
Watchers | Vue.js
https://vuejs.org/guide/essentials/event-handling.html
Event Handling ​ Watch a free video lesson on Vue School Listening to Events ​ We can use the v-on directive, which we typically shorten to the @ symbol, to listen to DOM events and run some JavaScript when they're triggered. The usage would be v-on:click="handler" or with the shortcut, @click="handler". The handler ...
Event Handling | Vue.js
https://vuejs.org/guide/essentials/forms.html
Form Input Bindings ​ Watch a free video lesson on Vue School When dealing with forms on the frontend, we often need to sync the state of form input elements with corresponding state in JavaScript. It can be cumbersome to manually wire up value bindings and change event listeners: template <input :value="text" @i...
Form Input Bindings | Vue.js
https://vuejs.org/guide/essentials/conditional.html
Conditional Rendering ​ Watch a free video lesson on Vue School v-if ​ The directive v-if is used to conditionally render a block. The block will only be rendered if the directive's expression returns a truthy value. template <h1 v-if="awesome">Vue is awesome!</h1> v-else ​ You can use the v-else directive to indica...
Conditional Rendering | Vue.js
https://vuejs.org/guide/essentials/list.html
List Rendering ​ Watch a free video lesson on Vue School v-for ​ We can use the v-for directive to render a list of items based on an array. The v-for directive requires a special syntax in the form of item in items, where items is the source data array and item is an alias for the array element being iterated on: js...
List Rendering | Vue.js
https://vuejs.org/guide/essentials/class-and-style.html
Class and Style Bindings ​ A common need for data binding is manipulating an element's class list and inline styles. Since class and style are both attributes, we can use v-bind to assign them a string value dynamically, much like with other attributes. However, trying to generate those values using string concatenati...
Class and Style Bindings | Vue.js
https://vuejs.org/guide/essentials/computed.html
Computed Properties ​ Watch a free video lesson on Vue School Basic Example ​ In-template expressions are very convenient, but they are meant for simple operations. Putting too much logic in your templates can make them bloated and hard to maintain. For example, if we have an object with a nested array: js const auth...
Computed Properties | Vue.js
https://vuejs.org/guide/essentials/template-syntax.html
Template Syntax ​ Vue uses an HTML-based template syntax that allows you to declaratively bind the rendered DOM to the underlying component instance's data. All Vue templates are syntactically valid HTML that can be parsed by spec-compliant browsers and HTML parsers. Under the hood, Vue compiles the templates into hi...
Template Syntax | Vue.js
https://vuejs.org/guide/essentials/reactivity-fundamentals.html
Reactivity Fundamentals ​ API Preference This page and many other chapters later in the guide contain different content for the Options API and the Composition API. Your current preference is Composition API. You can toggle between the API styles using the "API Preference" switches at the top of the left sidebar. De...
Reactivity Fundamentals | Vue.js
https://vuejs.org/guide/essentials/application.html
Creating a Vue Application ​ The application instance ​ Every Vue application starts by creating a new application instance with the createApp function: js import { createApp } from 'vue' const app = createApp({ /* root component options */ }) The Root Component ​ The object we are passing into createApp is in fa...
Creating a Vue Application | Vue.js
https://vuejs.org/guide/scaling-up/tooling.html
Tooling ​ Try It Online ​ You don't need to install anything on your machine to try out Vue SFCs - there are online playgrounds that allow you to do so right in the browser: Vue SFC Playground Always deployed from latest commit Designed for inspecting component compilation results Vue + Vite on StackBlitz IDE-like en...
Tooling | Vue.js
https://vuejs.org/guide/quick-start.html
Quick Start ​ Try Vue Online ​ To quickly get a taste of Vue, you can try it directly in our Playground. If you prefer a plain HTML setup without any build steps, you can use this JSFiddle as your starting point. If you are already familiar with Node.js and the concept of build tools, you can also try a complete bui...
Quick Start | Vue.js
https://vuejs.org/guide/introduction.html
Introduction ​ You are reading the documentation for Vue 3! Vue 2 support will end on Dec 31, 2023. Learn more about Vue 2 Extended LTS. Vue 2 documentation has been moved to v2.vuejs.org. Upgrading from Vue 2? Check out the Migration Guide. Learn Vue with video tutorials on VueMastery.com What is Vue? ​ Vue (pron...
Introduction | Vue.js
https://vuejs.org/guide/introduction.html
Introduction ​ You are reading the documentation for Vue 3! Vue 2 support will end on Dec 31, 2023. Learn more about Vue 2 Extended LTS. Vue 2 documentation has been moved to v2.vuejs.org. Upgrading from Vue 2? Check out the Migration Guide. Learn Vue with video tutorials on VueMastery.com What is Vue? ​ Vue (pron...
Introduction | Vue.js
https://vuejs.org/api/custom-renderer.html#VPContent
Custom Renderer API ​ createRenderer() ​ Creates a custom renderer. By providing platform-specific node creation and manipulation APIs, you can leverage Vue's core runtime to target non-DOM environments. Type ts function createRenderer<HostNode, HostElement>( options: RendererOptions<HostNode, HostElement> ): Rend...
Custom Renderer API | Vue.js
https://vuejs.org/api/ssr.html#VPContent
Server-Side Rendering API ​ renderToString() ​ Exported from vue/server-renderer Type ts function renderToString( input: App | VNode, context?: SSRContext ): Promise<string> Example js import { createSSRApp } from 'vue' import { renderToString } from 'vue/server-renderer' const app = createSSRApp({ data: ()...
Server-Side Rendering API | Vue.js
https://vuejs.org/api/utility-types.html#VPContent
Utility Types ​ INFO This page only lists a few commonly used utility types that may need explanation for their usage. For a full list of exported types, consult the source code. PropType<T> ​ Used to annotate a prop with more advanced types when using runtime props declarations. Example ts import type { PropType...
Utility Types | Vue.js
https://vuejs.org/api/render-function.html#VPContent
Render Function APIs ​ h() ​ Creates virtual DOM nodes (vnodes). Type ts // full signature function h( type: string | Component, props?: object | null, children?: Children | Slot | Slots ): VNode // omitting props function h(type: string | Component, children?: Children | Slot): VNode type Children = string ...
Render Function APIs | Vue.js
https://vuejs.org/api/sfc-css-features.html#VPContent
SFC CSS Features ​ Scoped CSS ​ When a <style> tag has the scoped attribute, its CSS will apply to elements of the current component only. This is similar to the style encapsulation found in Shadow DOM. It comes with some caveats, but doesn't require any polyfills. It is achieved by using PostCSS to transform the foll...
SFC CSS Features | Vue.js
https://vuejs.org/api/sfc-script-setup.html#VPContent
<script setup> ​ <script setup> is a compile-time syntactic sugar for using Composition API inside Single-File Components (SFCs). It is the recommended syntax if you are using both SFCs and Composition API. It provides a number of advantages over the normal <script> syntax: More succinct code with less boilerplate Ab...
<script setup> | Vue.js
https://vuejs.org/api/sfc-spec.html#VPContent
SFC Syntax Specification ​ Overview ​ A Vue Single-File Component (SFC), conventionally using the *.vue file extension, is a custom file format that uses an HTML-like syntax to describe a Vue component. A Vue SFC is syntactically compatible with HTML. Each *.vue file consists of three types of top-level language bloc...
SFC Syntax Specification | Vue.js
https://vuejs.org/api/built-in-special-attributes.html#VPContent
Built-in Special Attributes ​ key ​ The key special attribute is primarily used as a hint for Vue's virtual DOM algorithm to identify vnodes when diffing the new list of nodes against the old list. Expects: number | string | symbol Details Without keys, Vue uses an algorithm that minimizes element movement and trie...
Built-in Special Attributes | Vue.js
https://vuejs.org/api/built-in-special-elements.html#VPContent
Built-in Special Elements ​ Not Components <component>, <slot> and <template> are component-like features and part of the template syntax. They are not true components and are compiled away during template compilation. As such, they are conventionally written with lowercase in templates. <component> ​ A "meta compo...
Built-in Special Elements | Vue.js
https://vuejs.org/api/built-in-components.html#VPContent
Built-in Components ​ Registration and Usage Built-in components can be used directly in templates without needing to be registered. They are also tree-shakeable: they are only included in the build when they are used. When using them in render functions, they need to be imported explicitly. For example: js import ...
Built-in Components | Vue.js
https://vuejs.org/api/component-instance.html#VPContent
Component Instance ​ INFO This page documents the built-in properties and methods exposed on the component public instance, i.e. this. All properties listed on this page are readonly (except nested properties in $data). $data ​ The object returned from the data option, made reactive by the component. The component...
Component Instance | Vue.js
https://vuejs.org/api/built-in-directives.html#VPContent
Built-in Directives ​ v-text ​ Update the element's text content. Expects: string Details v-text works by setting the element's textContent property, so it will overwrite any existing content inside the element. If you need to update the part of textContent, you should use mustache interpolations instead. Example ...
Built-in Directives | Vue.js
https://vuejs.org/api/options-misc.html#VPContent
Options: Misc ​ name ​ Explicitly declare a display name for the component. Type ts interface ComponentOptions { name?: string } Details The name of a component is used for the following: Recursive self-reference in the component's own template Display in Vue DevTools' component inspection tree Display in warni...
Options: Misc | Vue.js
https://vuejs.org/api/options-composition.html#VPContent
Options: Composition ​ provide ​ Provide values that can be injected by descendant components. Type ts interface ComponentOptions { provide?: object | ((this: ComponentPublicInstance) => object) } Details provide and inject are used together to allow an ancestor component to serve as a dependency injector for al...
Options: Composition | Vue.js
https://vuejs.org/api/options-lifecycle.html#VPContent
Options: Lifecycle ​ See also For shared usage of lifecycle hooks, see Guide - Lifecycle Hooks beforeCreate ​ Called when the instance is initialized. Type ts interface ComponentOptions { beforeCreate?(this: ComponentPublicInstance): void } Details Called immediately when the instance is initialized, after pr...
Options: Lifecycle | Vue.js
https://vuejs.org/api/options-rendering.html#VPContent
Options: Rendering ​ template ​ A string template for the component. Type ts interface ComponentOptions { template?: string } Details A template provided via the template option will be compiled on-the-fly at runtime. It is only supported when using a build of Vue that includes the template compiler. The templat...
Options: Rendering | Vue.js
https://vuejs.org/api/options-state.html#VPContent
Options: State ​ data ​ A function that returns the initial reactive state for the component instance. Type ts interface ComponentOptions { data?( this: ComponentPublicInstance, vm: ComponentPublicInstance ): object } Details The function is expected to return a plain JavaScript object, which will be m...
Options: State | Vue.js
https://vuejs.org/api/composition-api-lifecycle.html#VPContent
Composition API: Lifecycle Hooks ​ Usage Note All APIs listed on this page must be called synchronously during the setup() phase of a component. See Guide - Lifecycle Hooks for more details. onMounted() ​ Registers a callback to be called after the component has been mounted. Type ts function onMounted(callback: ...
Composition API: Lifecycle Hooks | Vue.js
https://vuejs.org/api/composition-api-dependency-injection.html#VPContent
Composition API: Dependency Injection ​ provide() ​ Provides a value that can be injected by descendant components. Type ts function provide<T>(key: InjectionKey<T> | string, value: T): void Details provide() takes two arguments: the key, which can be a string or a symbol, and the value to be injected. When using...
Composition API: Dependency Injection | Vue.js
https://vuejs.org/api/reactivity-advanced.html#VPContent
Reactivity API: Advanced ​ shallowRef() ​ Shallow version of ref(). Type ts function shallowRef<T>(value: T): ShallowRef<T> interface ShallowRef<T> { value: T } Details Unlike ref(), the inner value of a shallow ref is stored and exposed as-is, and will not be made deeply reactive. Only the .value access is rea...
Reactivity API: Advanced | Vue.js
https://vuejs.org/api/reactivity-core.html#VPContent
Reactivity API: Core ​ See also To better understand the Reactivity APIs, it is recommended to read the following chapters in the guide: Reactivity Fundamentals (with the API preference set to Composition API) Reactivity in Depth ref() ​ Takes an inner value and returns a reactive and mutable ref object, which has ...
Reactivity API: Core | Vue.js
https://vuejs.org/api/composition-api-setup.html#VPContent
Composition API: setup() ​ Basic Usage ​ The setup() hook serves as the entry point for Composition API usage in components in the following cases: Using Composition API without a build step; Integrating with Composition-API-based code in an Options API component. Note If you are using Composition API with Single-F...
Composition API: setup() | Vue.js
https://vuejs.org/api/reactivity-utilities.html#VPContent
Reactivity API: Utilities ​ isRef() ​ Checks if a value is a ref object. Type ts function isRef<T>(r: Ref<T> | unknown): r is Ref<T> Note the return type is a type predicate, which means isRef can be used as a type guard: ts let foo: unknown if (isRef(foo)) { // foo's type is narrowed to Ref<unknown> foo.value...
Reactivity API: Utilities | Vue.js
https://vuejs.org/api/general.html#VPContent
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 stat...
Global API: General | Vue.js
https://vuejs.org/api/custom-renderer.html
Custom Renderer API ​ createRenderer() ​ Creates a custom renderer. By providing platform-specific node creation and manipulation APIs, you can leverage Vue's core runtime to target non-DOM environments. Type ts function createRenderer<HostNode, HostElement>( options: RendererOptions<HostNode, HostElement> ): Rend...
Custom Renderer API | Vue.js
https://vuejs.org/api/ssr.html
Server-Side Rendering API ​ renderToString() ​ Exported from vue/server-renderer Type ts function renderToString( input: App | VNode, context?: SSRContext ): Promise<string> Example js import { createSSRApp } from 'vue' import { renderToString } from 'vue/server-renderer' const app = createSSRApp({ data: ()...
Server-Side Rendering API | Vue.js
https://vuejs.org/api/utility-types.html
Utility Types ​ INFO This page only lists a few commonly used utility types that may need explanation for their usage. For a full list of exported types, consult the source code. PropType<T> ​ Used to annotate a prop with more advanced types when using runtime props declarations. Example ts import type { PropType...
Utility Types | Vue.js
https://vuejs.org/api/render-function.html
Render Function APIs ​ h() ​ Creates virtual DOM nodes (vnodes). Type ts // full signature function h( type: string | Component, props?: object | null, children?: Children | Slot | Slots ): VNode // omitting props function h(type: string | Component, children?: Children | Slot): VNode type Children = string ...
Render Function APIs | Vue.js
https://vuejs.org/api/sfc-css-features.html
SFC CSS Features ​ Scoped CSS ​ When a <style> tag has the scoped attribute, its CSS will apply to elements of the current component only. This is similar to the style encapsulation found in Shadow DOM. It comes with some caveats, but doesn't require any polyfills. It is achieved by using PostCSS to transform the foll...
SFC CSS Features | Vue.js
https://vuejs.org/api/sfc-script-setup.html
<script setup> ​ <script setup> is a compile-time syntactic sugar for using Composition API inside Single-File Components (SFCs). It is the recommended syntax if you are using both SFCs and Composition API. It provides a number of advantages over the normal <script> syntax: More succinct code with less boilerplate Ab...
<script setup> | Vue.js
https://vuejs.org/api/sfc-spec.html
SFC Syntax Specification ​ Overview ​ A Vue Single-File Component (SFC), conventionally using the *.vue file extension, is a custom file format that uses an HTML-like syntax to describe a Vue component. A Vue SFC is syntactically compatible with HTML. Each *.vue file consists of three types of top-level language bloc...
SFC Syntax Specification | Vue.js
https://vuejs.org/api/built-in-special-attributes.html
Built-in Special Attributes ​ key ​ The key special attribute is primarily used as a hint for Vue's virtual DOM algorithm to identify vnodes when diffing the new list of nodes against the old list. Expects: number | string | symbol Details Without keys, Vue uses an algorithm that minimizes element movement and trie...
Built-in Special Attributes | Vue.js
https://vuejs.org/api/built-in-special-elements.html
Built-in Special Elements ​ Not Components <component>, <slot> and <template> are component-like features and part of the template syntax. They are not true components and are compiled away during template compilation. As such, they are conventionally written with lowercase in templates. <component> ​ A "meta compo...
Built-in Special Elements | Vue.js