diff --git a/source/snippets/vue/index.md b/source/snippets/vue/index.md index bfdef3c..033d0d9 100644 --- a/source/snippets/vue/index.md +++ b/source/snippets/vue/index.md @@ -96,3 +96,127 @@ Basic Vue Component Scaffold. } ``` + +### Component with conditional template + +```html + + + +``` + +### Component using Vue 3 Composition API + +Basic Vue Component with Vue 3 Composition API. + +```html + + + + + +``` + +### Component using Vue 3 Composition API with click event and data binding + +```html + + + + + +``` + +### Slots in Vue + +Question : What is slots in vue js ? +Answer : Slots are a mechanism for Vue components that allows you to compose your components in a way other than the strict parent-child relationship. Slots give you an outlet to place content in new places or make components more generic +In other way we can say slots can be use to place any content inside children from parent, let see in above example : + +```html +// child.vue + +``` + +Here is simple child component which has slots inside. let's move to the parent component which App.vue, + +```html +// app.vue + +``` + +So simply we're using child component in App.vue(parent component) & passing it an image element as a slot so +it will render inside child component & replace `` to the image element. +So we can pass anything through the slots.