// This code is an example demonstrating the situation described in this Gist:
// https://gist.github.com/Loilo/73c55ed04917ecf5d682ec70a2a1b8e2
const A = {
template: `<div><slot name="a">Default A Content</slot><slot>Default C</slot></div>`
}
const B = {
template: `<div><slot name="b">Default B Content</slot></div>`
}
const C = {
template: `<div><slot name="c">Default C Content</slot></div>`
}
const D = {
template: `<div><slot name="d" emoji="🎉">Default D Content</slot></div>`
}
Vue.component('W', {
props: ['child'],
template: `<div :is="child">
<slot v-for="(_, name) in $slots" :name="name" :slot="name" />
<template v-for="(_, name) in $scopedSlots" :slot="name" slot-scope="slotData"><slot :name="name" v-bind="slotData" /></template>
</div>`
})
new Vue({
el: '#app',
template: `<W :child="C"><span slot="d" slot-scope="{ emoji }">Special D Content with scoped data: {{ emoji }}</span></W>`,
data: {
A, B, C, D
}
})
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.