1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| <template> <a-table> <slot></slot> <!-- 处理 scopedSlots --> <template v-for="slotName of scopedSlotsKeys" :slot="slotName"> <slot :name="slotName"></slot> </template> <!-- 处理 slots --> <template v-for="slotName of slotsKeys" v-slot:[slotName]> <slot :name="slotName"></slot> </template> </a-table> </template>
<script> computed: { slotsKeys() { return Object.keys(this.$slots).filter((key) => !this.usedSlots.includes(key)) }, scopedSlotsKeys() { return Object.keys(this.$scopedSlots).filter((key) => !this.usedSlots.includes(key)) }, }, </script>
|