mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-08-22 03:49:45 +08:00
21 lines
397 B
TypeScript
21 lines
397 B
TypeScript
/**
|
|
* Use scopedSlots in Vue 2.6+
|
|
* downgrade to slots in lower version
|
|
*/
|
|
import Vue from 'vue';
|
|
|
|
export const SlotsMixin = Vue.extend({
|
|
methods: {
|
|
slots(name = 'default', props: any) {
|
|
const { $slots, $scopedSlots } = this;
|
|
const scopedSlot = $scopedSlots[name];
|
|
|
|
if (scopedSlot) {
|
|
return scopedSlot(props);
|
|
}
|
|
|
|
return $slots[name];
|
|
},
|
|
},
|
|
});
|