Question 27
Consider the following Vue application with markup “index.html” and javascript file “app.js”.
index.html:
<div id = "app"> <my-comp> <template v-slot:first = "slotProps"> This is from {{slotProps.user.name1}} template </template>
<template v-slot:default = "slotProps"> This is from {{slotProps.user.name3}} template </template>
<template v-slot:second = "slotProps"> This is from {{slotProps.user.name2}} template </template> </my-comp></div><script src = "app.js"> </script>app.js:
Vue.component("myComp", { template : `<div> <p> <slot name = "first" v-bind:user="user"> </slot> </p> <p> <slot v-bind:user="user"> </slot> </p> </div> `, data : function () { return { user : { 'name1' : "Rashmi's", 'name2' : "Akshay's", 'name3' : "Sumit's", } } }})
const app = new Vue({ el : "#app",})This is from template
This is from templateThis is from Rashmi’s template
This is from Akshay’s template
This is from Sumit’s templateThis is from Rashmi’s template
This is from Sumit’s templateThis is from Rashmi’s template
This is from Sumit’s template
This is from Akshay’s templateThis is from template
This is from template
This is from template