Vue tips · 132 tips

Vue & Nuxt tips

Over the last few years, I've collected a list of valuable tips while developing and writing about Vue & Nuxt. Some are clever, some I use almost every day, and some are more advanced — but they're all useful.

Vue Tip: Use Teleport to Render a Component in a Different Place Image

Vue Tip: Use Teleport to Render a Component in a Different Place

With teleport, you can render a component in a different place in the DOM tree, even if this place is not in your app's scope.
Vue Tip: Assign Handler for Uncaught Errors Image

Vue Tip: Assign Handler for Uncaught Errors

Error monitoring is important in production, and we can use the errorHandler function to send errors to error tracking services.
Vue Tip: Simple Expressions in Templates Image

Vue Tip: Simple Expressions in Templates

Vue component templates should only include simple expressions, with more complex expressions refactored into computed properties or methods.
Vue Tip: Trigger Watcher Immediately Image

Vue Tip: Trigger Watcher Immediately

The watch hook provides an option that the callback is called immediately.
Vue Tip: Use Multiple v-model Bindings Image

Vue Tip: Use Multiple v-model Bindings

Sometimes Vue.js components need to have multiple v-model bindings.
Vue Tip: Avoid Unwanted Re-Renders of an Element Using v-once Image

Vue Tip: Avoid Unwanted Re-Renders of an Element Using v-once

The v-once directive is a Vue.js directive used to avoid unwanted re-renders of an element.
Vue Tip: Destructure in v-for Image

Vue Tip: Destructure in v-for

It is possible to use ES6 destructuring in a v-for in Vue
Vue Tip: Avoid Empty Class Attributes Image

Vue Tip: Avoid Empty Class Attributes

This Vue tip helps to avoid empty class attributes in the rendered HTML
Vue Tip: Props and Context in Setup Method Image

Vue Tip: Props and Context in Setup Method

Access props and context in setup method using Composition API in Vue 3
Vue Tip: Detailed Prop Definitions Image

Vue Tip: Detailed Prop Definitions

Define your Vue prop definitions as detailed as possible.