mirror of
https://github.com/youzan/vant.git
synced 2025-10-19 10:07:07 +00:00
[improvement] Cell: functional (#2729)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { RenderContext, VNodeData } from 'vue';
|
||||
import { RenderContext, VNodeData } from 'vue/types';
|
||||
import { ScopedSlot } from 'vue/types/vnode';
|
||||
|
||||
type ObjectIndex = {
|
||||
[key: string]: any;
|
||||
@@ -40,9 +41,23 @@ export function emit(context: Context, eventName: string, ...args: any[]) {
|
||||
if (Array.isArray(listeners)) {
|
||||
listeners.forEach(listener => {
|
||||
listener(...args);
|
||||
})
|
||||
});
|
||||
} else {
|
||||
listeners(...args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// unify slots & scopedSlots
|
||||
export function unifySlots(context: Context) {
|
||||
const { scopedSlots } = context;
|
||||
const slots = context.slots();
|
||||
|
||||
Object.keys(slots).forEach(key => {
|
||||
if (!scopedSlots[key]) {
|
||||
scopedSlots[key] = () => slots[key];
|
||||
}
|
||||
});
|
||||
|
||||
return scopedSlots;
|
||||
}
|
||||
|
Reference in New Issue
Block a user