mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore(Switch): useParentField
This commit is contained in:
parent
c1e9323f95
commit
902a1b7c63
@ -33,7 +33,7 @@ export default createComponent({
|
|||||||
duration={0.2}
|
duration={0.2}
|
||||||
lockScroll={false}
|
lockScroll={false}
|
||||||
>
|
>
|
||||||
{slots.default?.() || props.message}
|
{slots.default ? slots.default() : props.message}
|
||||||
</Popup>
|
</Popup>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
import { createNamespace, addUnit } from '../utils';
|
import { createNamespace, addUnit } from '../utils';
|
||||||
import { switchProps } from './shared';
|
import { switchProps } from './shared';
|
||||||
|
|
||||||
// Mixins
|
// Composition
|
||||||
import { FieldMixin } from '../mixins/field';
|
import { useParentField } from '../composition/use-parent-field';
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import Loading from '../loading';
|
import Loading from '../loading';
|
||||||
@ -11,8 +11,6 @@ import Loading from '../loading';
|
|||||||
const [createComponent, bem] = createNamespace('switch');
|
const [createComponent, bem] = createNamespace('switch');
|
||||||
|
|
||||||
export default createComponent({
|
export default createComponent({
|
||||||
mixins: [FieldMixin],
|
|
||||||
|
|
||||||
props: switchProps,
|
props: switchProps,
|
||||||
|
|
||||||
emits: ['change', 'update:modelValue'],
|
emits: ['change', 'update:modelValue'],
|
||||||
@ -35,6 +33,8 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useParentField(() => props.modelValue);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
const { size, loading, disabled, activeColor, inactiveColor } = props;
|
const { size, loading, disabled, activeColor, inactiveColor } = props;
|
||||||
const checked = isChecked();
|
const checked = isChecked();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user