mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 02:31:21 +00:00
[improvement] Use scoped-slots in Vue 2.6+ (#2688)
This commit is contained in:
@@ -6,12 +6,3 @@ export function use(name) {
|
||||
name = 'van-' + name;
|
||||
return [useSfc(name), useBem(name), useI18n(name)];
|
||||
}
|
||||
|
||||
export function useSlots({ $slots, $scopedSlots }) {
|
||||
return (name, props) => {
|
||||
if ($scopedSlots[name]) {
|
||||
return $scopedSlots[name](props);
|
||||
}
|
||||
return $slots[name];
|
||||
};
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
import '../../locale';
|
||||
import { camelize } from '..';
|
||||
import SlotsMixin from '../../mixins/slots';
|
||||
|
||||
const arrayProp = {
|
||||
type: Array,
|
||||
@@ -50,6 +51,8 @@ function functional(sfc) {
|
||||
export default name => (sfc, isFunctional) => {
|
||||
sfc.name = name;
|
||||
sfc.install = install;
|
||||
sfc.mixins = sfc.mixins || [];
|
||||
sfc.mixins.push(SlotsMixin);
|
||||
|
||||
if (sfc.props) {
|
||||
defaultProps(sfc.props);
|
||||
|
Reference in New Issue
Block a user