Vue-Tipps · 132 Tipps

Vue- & Nuxt-Tipps

In den letzten Jahren habe ich beim Entwickeln und Schreiben über Vue & Nuxt eine Liste wertvoller Tipps gesammelt. Einige sind clever, einige benutze ich fast jeden Tag, und einige sind fortgeschrittener - aber sie sind alle nützlich.

#103

Vue Tip: Use a Head Manager

Unhead is a framework-agnostic document head manager that can be used to manage page metadata like the title in your Vue application.

1 Min.Script
#100

Vue Tip: Accessing Template Ref in Child Component

Learn how to access template refs in a child component within a Vue.js application, enabling you to manipulate and interact with specific elements in the child component's template from the parent component.

1 Min.Template
#98

Vue Tip: Dynamic Slot Names

Dynamic directive arguments also work on v-slot, allowing the definition of dynamic slot names.

1 Min.Template
#96

Vue Tip: Event Handling

There are different ways how to handle events in Vue. Let's take a look at them.

1 Min.Template
#95

Vue Tip: Use Your Composables Synchronously

You should always call your composables synchronously in setup() hook or <script setup>. Otherwise Vue will not be able to determine the current active component instance and cannot correctly register features like lifecycle hooks, watchers, and computed properties.

2 Min.Script
#94

Nuxt Tip: Custom SPA Loading Template for Your Nuxt Application

When using the client-side rendering mode, Nuxt will display a loading indicator until the application is hydrated. The loading indicator is a simple spinner. You can customize the loading indicator by creating a custom loading component.

1 Min.Nuxt
#93

Vue Tip: Deep Watch on Arrays

In Vue 3, when using the watch option to watch an array, the callback will only trigger when the array is replaced. To trigger the watcher on mutation, the deep option must be specified.

1 Min.Script
#90

Vue Tip: Manually Stop Watcher

You need to manually stop your Vue watcher if they are created asynchronously. Sync watchers are automatically stopped when the component is unmounted.

1 Min.Script
#87

Vue Tip: Emit Event From Composable

Your application may contain a lot of components that are using the same logic, like emitting the same event. In this case, it might be tempting to create a composable that will emit this event and is used in all components. But how do you emit an event from inside a composable?

2 Min.Script
Seite 2 von 6