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
+7 -4
View File
@@ -1,7 +1,7 @@
import { pick, createNamespace } from '../utils';
import { useParent } from '@vant/use';
import Checker, { checkerProps } from '../checkbox/Checker';
import { RADIO_KEY } from '../radio-group';
import { RADIO_KEY, RadioGroupProvide } from '../radio-group';
const [createComponent, bem] = createNamespace('radio');
@@ -11,7 +11,7 @@ export default createComponent({
emits: ['update:modelValue'],
setup(props, { emit, slots }) {
const { parent } = useParent(RADIO_KEY);
const { parent } = useParent<RadioGroupProvide>(RADIO_KEY);
const checked = () => {
const value = parent ? parent.props.modelValue : props.modelValue;
@@ -19,8 +19,11 @@ export default createComponent({
};
const toggle = () => {
const emitter = parent ? parent.emit : emit;
emitter('update:modelValue', props.name);
if (parent) {
parent.updateModelValue(props.name);
} else {
emit('update:modelValue', props.name);
}
};
return () => (