types(Radio): use tsx (#8129)
This commit is contained in:
@@ -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 () => (
|
||||
Reference in New Issue
Block a user