Vue: Add scopedSlots to functional component context

Created on 5 Apr 2017  路  2Comments  路  Source: vuejs/vue

What problem does this feature solve?

Currently, when attempting to use scoped slots in a functional component, the slot is entirely missing in the context.slots() and context.children. Example: http://codepen.io/kaleb/pen/qrwwye?editors=1010

What does the proposed API look like?

render(h, ctx) {
  var scopedSlots = ctx.scopedSlots();
  return h('ul', ctx.props.items.map(i => h('li', {}, scopedSlots.default ? scopedSlots({value: i}) : i)));
}

Most helpful comment

You can access them from context.data.scopedSlots

All 2 comments

You can access them from context.data.scopedSlots

More info at https://vuejs.org/v2/guide/render-function.html#The-Data-Object-In-Depth

Was this page helpful?
0 / 5 - 0 ratings