Skip to content

Instantly share code, notes, and snippets.

@Akryum

Akryum/example.js

Created Oct 14, 2017
Embed
What would you like to do?
Scoped slots + Apollo
Vue.component('SomeData', {
apollo: {
items: ITEMS_QUERY,
},
template: `
<div>
<slot :items="items"/>
</div>
`,
})
Vue.component('DisplayList', {
props: ['list'],
template: `
<ul>
<li v-for="item of list">{{ item.label }}</li>
</ul>
`,
})
Vue.component('MyItemList', {
template: `
<SomeData>
<DisplayList slot-scope="{ items }" :list="items" />
</SomeData>
`
})
new Vue({
el: '#app',
template: `
<div id="app">
<MyItemsList />
</div>
`,
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment