types(Radio): use tsx (#8129)
This commit is contained in:
@@ -2,17 +2,25 @@ import { watch } from 'vue';
|
||||
import { createNamespace } from '../utils';
|
||||
import { useChildren } from '@vant/use';
|
||||
import { useLinkField } from '../composables/use-link-field';
|
||||
import { CheckerParent } from '../checkbox/Checker';
|
||||
|
||||
const [createComponent, bem] = createNamespace('radio-group');
|
||||
|
||||
export const RADIO_KEY = 'vanRadio';
|
||||
|
||||
export type RadioGroupProvide = CheckerParent & {
|
||||
props: {
|
||||
modelValue: any;
|
||||
};
|
||||
updateModelValue: (value: unknown) => void;
|
||||
};
|
||||
|
||||
export default createComponent({
|
||||
props: {
|
||||
disabled: Boolean,
|
||||
iconSize: [Number, String],
|
||||
direction: String,
|
||||
modelValue: null,
|
||||
modelValue: null as any,
|
||||
checkedColor: String,
|
||||
},
|
||||
|
||||
@@ -21,6 +29,10 @@ export default createComponent({
|
||||
setup(props, { emit, slots }) {
|
||||
const { linkChildren } = useChildren(RADIO_KEY);
|
||||
|
||||
const updateModelValue = (value: unknown) => {
|
||||
emit('update:modelValue', value);
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(value) => {
|
||||
@@ -28,7 +40,11 @@ export default createComponent({
|
||||
}
|
||||
);
|
||||
|
||||
linkChildren({ emit, props });
|
||||
linkChildren({
|
||||
props,
|
||||
updateModelValue,
|
||||
});
|
||||
|
||||
useLinkField(() => props.modelValue);
|
||||
|
||||
return () => (
|
||||
Reference in New Issue
Block a user