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: watch() vs. watchEffect() Image

Vue Tip: watch() vs. watchEffect()

Understand the difference between the watch() and watchEffect() Vue hooks.
Vue Tip: Use Fallthrough Attributes Image

Vue Tip: Use Fallthrough Attributes

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 or emits. Common examples of this include class, style, and id attributes.
Vue Tip: Provide Fallback Content for Slots Image

Vue Tip: Provide Fallback Content for Slots

There are cases when it's useful to specify fallback (i.e. default) content for a slot, to be rendered only when no content is provided.
Vue Tip: Debug Computed Properties Image

Vue Tip: Debug Computed Properties

We can debug properties by passing computed() a second options object.
Vue Tip: Use Lazy v-model to Sync State After Change Events Image

Vue Tip: Use Lazy v-model to Sync State After Change Events

By default, v-model syncs with the state of the Vue instance on every input event. The .lazy modifier syncs after change events.
Vue Tip: Create Custom v-model Modifier Image

Vue Tip: Create Custom v-model Modifier

v-model has some built-in modifiers, but in some cases, you might need to add your custom modifier.
Vue Tip: Query Inner Elements in Third-Party Components Image

Vue Tip: Query Inner Elements in Third-Party Components

In some cases, we have to deal with third-party Vue components where we cannot put a ref on inner HTML elements to access them in our Vue code.
Vue Tip: Check Version at Runtime Image

Vue Tip: Check Version at Runtime

You can easily check the Vue version at runtime.
Vue Tip: Measure Performance Image

Vue Tip: Measure Performance

Learn some tools to measure the performance of your Vue application.
Vue Tip: Animate Child Component Before Route Leave Image

Vue Tip: Animate Child Component Before Route Leave

Vue Router provides a way to use transitions on route components and animate the navigations. But sometimes, you might want to animate a specific (sub-)component before a route is left.