Vue Tip: Watch Slot Changes
You can use the MutationObserver API to react to changes in the slot content.
Vue-Tipps · 132 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.
You can use the MutationObserver API to react to changes in the slot content.
Nuxt provides the NuxtErrorBoundary component to handle client-side errors.
In certain scenarios, Vue's reactivity approach isn’t sufficient, and we need to force re-rendering of specific components.
You can use JSDoc to document your component props so that they show up when you hover over the component in your IDE.
I show you a handy Vue composable that allows you to define keyboard shortcuts in your app.
Unhead is a framework-agnostic document head manager that can be used to manage page metadata like the title in your Vue application.
Use the unplugin-vue-components tool to automatically import your Vue components.
Build a simple history with undo and redo functionality using the useRefHistory composable from VueUse.
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.
If you are using Nuxt 3, you probably already encountered the 'Nuxt Instance Unavailable' error. What is it, and how to fix it?
Dynamic directive arguments also work on v-slot, allowing the definition of dynamic slot names.
Nuxt 3 provides a way to detect whether your code is running on the server or client-side.
There are different ways how to handle events in Vue. Let's take a look at them.
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.
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.
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.
Nuxt provides a helper function called useRequestURL that returns an URL object working on both server side and client side.
Learn how you can use Composition API for a simple state management solution which you can use instead of Pinia.
You need to manually stop your Vue watcher if they are created asynchronously. Sync watchers are automatically stopped when the component is unmounted.
FIXME
VueUse is a collection of hundreds of essential Vue Composition Utilities for interacting with various browsers, sensors, animations, and state APIs, and more.
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?
Use the 'src' attribute to import an external file for a language block in your Vue Single-File Components (SFC).
Nuxt allows you to define client-side and standalone server components