[improvement] mixins typescript (#3690)

This commit is contained in:
neverland
2019-06-29 11:31:53 +08:00
committed by GitHub
parent 0a79536a05
commit abe3e59bed
17 changed files with 135 additions and 82 deletions
+20
View File
@@ -0,0 +1,20 @@
/**
* 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];
}
}
});