Category · 43 articles

Template

Articles in the category Template.

Vue Tip: Cache Component Instances With the KeepAlive Component Image

Vue Tip: Cache Component Instances With the KeepAlive Component

KeepAlive is a built-in Vue component that allows you to conditionally cache component instances when dynamically switching between multiple components.
Vue Tip: How I Write Class & Style Bindings Image

Vue Tip: How I Write Class & Style Bindings

Styling your components in Vue.js can be done in multiple ways. One of the most common ways is to use the class attribute, especially if you are using a CSS framework like Tailwind. In combination with v-bind you can dynamically assign classes to your components.
Vue Tip: Share Styling Using Wrapper Components Image

Vue Tip: Share Styling Using Wrapper Components

Wrapper components can help you share styling across multiple Vue components. This can make your code cleaner and more maintainable.
Vue Tip: Don't Use Reactive Object for Template Refs Image

Vue Tip: Don't Use Reactive Object for Template Refs

Template Refs are a way to access elements in the DOM from within a Vue component. As the name suggests, you should use a ref to access the element in the template.
Vue Tip: Passing Slots to Child Components Image

Vue Tip: Passing Slots to Child Components

In certain scenarios, you need to pass on all slots from a parent component to the child component.
Vue Tip: Check if Component Has Event Listener Attached Image

Vue Tip: Check if Component Has Event Listener Attached

Sometimes, you want to apply specific styles to a component only if it has an event listener attached.
Vue Tip: Watch Slot Changes Image

Vue Tip: Watch Slot Changes

You can use the MutationObserver API to react to changes in the slot content.
Vue Tip: Best Way to Force Re-Render Vue Component Image

Vue Tip: Best Way to Force Re-Render Vue Component

In certain scenarios, Vue's reactivity approach isn’t sufficient, and we need to force re-rendering of specific components.
Vue Tip: Accessing Template Ref in Child Component Image

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.
Vue Tip: Dynamic Slot Names Image

Vue Tip: Dynamic Slot Names

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