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.

#36

Vue Tip: Avoid Empty Wrapper for Conditions

There are many situations when you need to conditionally display multiple Vue components. To avoid "empty" wrappers you should use not use HTML tags.

1 minTemplate
#35

Vue Tip: Delay Loading Appearance of Spinner

Eager delay spinners are not a good user experience. They can make a snappy user interface feel slower. We want delay spinners to appear only after a perceivable delay.

1 minTemplate
#31

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.

2 minTemplate
#23

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.

1 minRouter
#17

Vue Tip: Use Two Script Blocks

<script setup> can be used alongside normal <script>. A normal <script> may be needed in special cases.

1 minScript
#14

Vue Tip: Display Raw HTML

The double mustaches interpret the data as plain text, not HTML. To output real HTML, you will need to use the v-html directive.

1 minTemplate
Page 5 of 6