Created
October 14, 2017 15:06
-
-
Save Akryum/dad7acd824d822944e52d49f4c483609 to your computer and use it in GitHub Desktop.
Scoped slots + Apollo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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