3

I'd like to do the following, but with Vue 2's render function

<template>
  <imported-component>
    <template v-slot:default="{ importedFunction }">
       <button @click="importedFunction">Do something</button>
    </template>
  </import-component>
</template>
Dan
  • 59,490
  • 13
  • 101
  • 110
Mysterywood
  • 1,378
  • 2
  • 10
  • 19

1 Answers1

2
  • Use scopedSlots for the slot
  • Use the slot name ("default") plus function argument for the slot props
  • Use on for the event handler
render(h) {
  return h('imported-component', {
    scopedSlots: {
      default(slotProps) {
        return h('button', {
          on: {
            click: slotProps.importedFunction
          }
        }, 'Do something')
      }
    }
  });
}
Dan
  • 59,490
  • 13
  • 101
  • 110