types(Radio): use tsx (#8129)

This commit is contained in:
neverland
2021-02-11 10:35:22 +08:00
committed by GitHub
parent b5944524d9
commit 4ce467c683
4 changed files with 31 additions and 13 deletions
@@ -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 () => (