Skip to content

Instantly share code, notes, and snippets.

@Akryum
Created October 14, 2017 15:06
Show Gist options
  • Save Akryum/dad7acd824d822944e52d49f4c483609 to your computer and use it in GitHub Desktop.
Save Akryum/dad7acd824d822944e52d49f4c483609 to your computer and use it in GitHub Desktop.
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