programing

Vue 2 렌더 기능에서 슬롯을 사용하는 방법

minecode 2022. 7. 18. 22:28
반응형

Vue 2 렌더 기능에서 슬롯을 사용하는 방법

다음을 하고 싶은데 Vue 2의 렌더링 기능을 사용하여

<template>
  <imported-component>
    <template v-slot:default="{ importedFunction }">
       <button @click="importedFunction">Do something</button>
    </template>
  </import-component>
</template>
  • scopedSlots
  • 슬롯 소품에는 slot name(기본값) + function 인수를 사용합니다.
  • on의 경우
render(h) {
  return h('imported-component', {
    scopedSlots: {
      default(slotProps) {
        return h('button', {
          on: {
            click: slotProps.importedFunction
          }
        }, 'Do something')
      }
    }
  });
}

언급URL : https://stackoverflow.com/questions/65662621/how-to-use-slot-in-vue-2-render-function

반응형