Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

vue.js slots

Parent Component :
<template>
  <Child>
    <template v-slot:header>
      <h1>Header </h1>
    </template>

    <template v-slot:content>
      <h1> Content </h1>
    </template>

    <template v-slot:footer>
      <h1>Footer</h1>
    </template>
  </Child>
</template>

Child component :

<template>
  <slot name="header">Default Value</slot>
  <slot name="content">Default Value</slot>
  <slot name="footer">Default Value</slot>
</template>
Comment

slot vuetify js

<button type="submit">
  <slot>Envoyer</slot>
</button>
Comment

use of slot in vue

/*first component*/
<template>
  <header>
    <h2>{{ msg }}</h2>
  </header>
  <div>
    <the-card cardTitle="About Me">
       <p>Hi,Iam Mamunur Rashid Rimon, blah blah</p>
    </the-card>
    <the-card cardTitle="Apple iPhone 12 Pro">
      <img
        src="https://fdn2.gsmarena.com/vv/bigpic"
        alt=""
      />
      <p>
        Versions: A2407 (International); A2341 (USA)
        A2408 (China, Hong Kong)
      </p>
    </the-card>
    <the-card cardTitle="Services">I
      <ul>
       <li>Web Development</li>
      </ul>
    </the-card>
  </div>
</template>
<script>
import TheCard from "./TheCard.vue";
export default{
  data(){
    return{
      msg: "Vue3 Bangla Tutorial"
    };
  },
  components:{
    TheCard
};
</script>


/*first component*/






/*second component*/
<template>
  <div class="the-card">
    <div class="the-card_title">
     {{ cardTitle }}
    </div>
    <div class="the-card_body">
    <slot>default value if slot is empty</slot>
    </div>
  </div>
</template>
<script>
export default{
 props: ["cardTitle"]
};
</script>

/*second component*/
Comment

what is slot in vue.js

// app.vue
<template>
  <current-user>
    <template v-slot:default="slotProps">{{ slotProps.user.firstName }}</template>    
  </current-user>
</template>
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to assign an rest operator in javascript 
Javascript :: javascript interview questions 
Javascript :: Javascript Scrape content from a website source code 
Javascript :: extract data from pdf nodejs 
Javascript :: string get a letter by index 
Javascript :: js function arguments 
Javascript :: destructuring in javascript 
Javascript :: js unshift vs push 
Javascript :: values javascript 
Javascript :: tofixed in javascript 
Javascript :: javascript post 
Javascript :: python json replace string 
Javascript :: closure example 
Javascript :: how to download json object that come from backend in react 
Javascript :: object.assign in node.js 
Javascript :: preview file before upload in react 
Javascript :: spread operator react array 
Javascript :: jetty 
Javascript :: Find the maximum number of an array js 
Javascript :: discord message reply 
Javascript :: cheerio each 
Javascript :: serializes to the same string 
Javascript :: javascript find ip and information 
Javascript :: id in class selector jquery 
Javascript :: how to wait for the subscribe to finish before going back to caller method in angular 
Javascript :: javascript interface class 
Javascript :: enzyme find selector 
Javascript :: fetch log api response time 
Javascript :: how to create a search engine with javascript 
Javascript :: what is the use of consrtructors in reactjs 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =