Skip to content

A demo showcasing the power of slots and how to make dynamic slots using VueJS

Notifications You must be signed in to change notification settings

maxshuty/vue-dynamic-slots

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vue Dynamic Slots example

Have you ever wondered how you can reorganize a components structure based on a given format? This repo demonstrates how this can be done using dynamic slots. The beauty of using a slot instead of an algorithm to dynamically generate the order is that the slots can be filled out and individually customized with whatever you need (ie custom validation for only one input and not all inputs).

Why is this useful?

In short because it displays the awesomeness of dynamic slots.

A good example of this use case for something like this would be address formats. Different countries have different formats, like Germany shows a different format from the United States or United Kingdom formats.

Perhaps you want to build an AddressDisplay component and you want the display order of the address to change depending on a given format, like how the U.S. postal format is different from the German postal format. Well you're in luck - with this repo have a look at the SlotsExample.vue. Follow this same logic to create a wrapper around your main address component like I have implemented in the App.vue and you can get a clean way to dynamically alter the order of your data based on a given format, yet still be able to easily add new fields and maintain existing fields.

Usage

Look at the App.vue, it is wrapped with the SlotsExample.vue component to dynamically change the order of the fields within App.vue.

Project setup

npm install

Compiles and hot-reloads for development

npm run dev

Compiles and minifies for production

npm run build

Lints and fixes files

npm run lint

Customize configuration

See Configuration Reference.

About

A demo showcasing the power of slots and how to make dynamic slots using VueJS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published