mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-23 06:59:15 +08:00
fix(ContactList): select event triggered twice
This commit is contained in:
parent
6d483a8da5
commit
1dd4083102
@ -23,28 +23,17 @@ export default createComponent({
|
||||
emits: ['add', 'edit', 'select', 'update:modelValue'],
|
||||
|
||||
setup(props, { emit }) {
|
||||
return () => {
|
||||
const List =
|
||||
props.list &&
|
||||
props.list.map((item, index) => {
|
||||
function onClick() {
|
||||
const renderItem = (item, index) => {
|
||||
const onClick = () => {
|
||||
emit('update:modelValue', item.id);
|
||||
emit('select', item, index);
|
||||
}
|
||||
};
|
||||
|
||||
function RightIcon() {
|
||||
return (
|
||||
<Radio
|
||||
name={item.id}
|
||||
iconSize={16}
|
||||
checkedColor={RED}
|
||||
onClick={onClick}
|
||||
/>
|
||||
const renderRightIcon = () => (
|
||||
<Radio name={item.id} iconSize={16} checkedColor={RED} />
|
||||
);
|
||||
}
|
||||
|
||||
function LeftIcon() {
|
||||
return (
|
||||
const renderLeftIcon = () => (
|
||||
<Icon
|
||||
name="edit"
|
||||
class={bem('edit')}
|
||||
@ -54,9 +43,8 @@ export default createComponent({
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function Content() {
|
||||
const renderContent = () => {
|
||||
const nodes = [`${item.name},${item.tel}`];
|
||||
|
||||
if (item.isDefault && props.defaultTagText) {
|
||||
@ -68,14 +56,14 @@ export default createComponent({
|
||||
}
|
||||
|
||||
return nodes;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Cell
|
||||
v-slots={{
|
||||
icon: LeftIcon,
|
||||
default: Content,
|
||||
'right-icon': RightIcon,
|
||||
icon: renderLeftIcon,
|
||||
default: renderContent,
|
||||
'right-icon': renderRightIcon,
|
||||
}}
|
||||
key={item.id}
|
||||
isLink
|
||||
@ -85,12 +73,12 @@ export default createComponent({
|
||||
onClick={onClick}
|
||||
/>
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
return () => (
|
||||
<div class={bem()}>
|
||||
<RadioGroup modelValue={props.modelValue} class={bem('group')}>
|
||||
{List}
|
||||
{props.list && props.list.map(renderItem)}
|
||||
</RadioGroup>
|
||||
<div class={bem('bottom')}>
|
||||
<Button
|
||||
@ -106,6 +94,5 @@ export default createComponent({
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
},
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user